A non-primitive data type, called String
, is used.
Note that comparing two strings does not use ==
, but equals()
. Example:
if (stringDigitada.equals("São Paulo")) {
...
}
You should look for a tutorial on Java. Or better, I do not know why you're learning basic programming with Java, whether it's college stuff or something. I think it would be best to start with a structured language and not an object-oriented language. Java is object oriented, which makes things more complicated, for example a String
is an object, which is a data type that has functions added to it (note in the example above that the object stringDigitada
has a function equals()
aggregated to it, which is being called this: stringDigitada.equals(...)
). These functions are called "methods".
If you want to learn programming and do not have a special reason to use Java, I suggest that you first choose a language that supports structured programming such as Python or C and then look for suitable learning material to guide you along that path, it can be a tutorial, book or video-lessons. Maybe even before doing this look for material to learn about something called "programming logic", which will probably be taught in some pseudolanguage such as Portugol (although it is possible to find material on programming logic already in the desired programming language). >
I hope these guidelines can be helpful.