The "==" operator is comparing references or primitive data types.
The "equals" method compares equality of objects based on the logic defined in the class.
For example:
String a = "Test";...
Type: Posts; User: Cornix
The "==" operator is comparing references or primitive data types.
The "equals" method compares equality of objects based on the logic defined in the class.
For example:
String a = "Test";...
What Norm means is that you have to do:
compChoice = "something";
to assign a value to it.
The equals method is only supposed to be used for conditional branches in your code. (if, while, etc)
System.out.println(...) will write to the default Output unless you specify a different output stream for it.
So by default it will write to the console window. If you are starting from an IDE there...
1) The for loop looks quite complicated and non-standard.
You should try to stick with the established standards to make the code easier readable by others (like us).
Usually a for-loop looks like...
If you want to have a loop run for a certain number of times prefer a for-loop over a while-loop.
Example of a for-loop running 17 times:
int a = 17;
for (int i = 0; i < a; i++) {
}
...