newcoder1010 Posted July 21, 2020 Share Posted July 21, 2020 Hello, I am practicing java from this link. https://www.w3schools.com/java/java_strings.asp JAVA String txt = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; System.out.println("The length of the txt string is: " + txt.length()); Quote Type mismatch: cannot convert from java.lang.String to DataTypesCasting.String Fixed it using the suggested fix: java.lang.String txt = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; Can you please tell me why I had to replace String by java.lang.String? Thanks! Link to comment Share on other sites More sharing options...
Ingolme Posted July 22, 2020 Share Posted July 22, 2020 It sounds like you are importing some packages with another class named "String". You have to specify java.lang.String because you have imported a different String class and it assumes you meant that other one. Link to comment Share on other sites More sharing options...
newcoder1010 Posted July 22, 2020 Author Share Posted July 22, 2020 Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now