Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - A few questions for JAVA beginners ... I am a beginner, so don't answer with too deep theory, just bring some simple understanding.
A few questions for JAVA beginners ... I am a beginner, so don't answer with too deep theory, just bring some simple understanding.
1, Scanner(System.in) input error will not loop indefinitely, because String s=sc.next () will only be executed once, and an infinite loop will occur because the following conditions do not match your input.

2.Use while (Boolean) {strings s = sc。 next(); } this way to judge whether the input meets the conditions you want.

3. The variable modified by 3.final has a special property: the value cannot be changed after assignment, so it is called constant in JAVA. For example, the circular area s = r 2 * π. π is a constant value, and finally double x = 3.14 can be used at this time; To create.

4. Whether the plastic direct comparison values are equal. Reference type variable = = compares whether the memory addresses of the two variables are equal, that is, whether they point to the same object. The equals method is to determine whether the contents of two variables are the same, regardless of the memory address. This is the default.

string s 1 = " 1 1 1 1 ";

String S2 = new String(" 1 1 1 1 ");

system . out . println(s 1 = = S2);

system . out . println(s 1 . equals(S2));

The outputs are false and true respectively.