Home > Back-end >  JAVA program
JAVA program

Time:12-07

What do you mean this watch don't understand, you bosses can give an explanation of the

CodePudding user response:

Add a space,
Look at this or write myself, execution

CodePudding user response:

The blank space after add count++ plus the output

CodePudding user response:

Understood as: the output=the output itself plus count++ and empty string ""

CodePudding user response:

Split the following
1. The output=the output + (count + "")
2. Count=count + 1
Pay attention to the next symbol can
+ on behalf of the first to take a, finally to perform a=a + 1, such as a=1, b=+, is first b=a=1, then a=1 + 1=2
+ + a representative plus 1 first, then take a, such as a=1, b=+ + a, that is to perform a=1 + 1=2, after b=a=2
Any type + string, + mean joining together here
Such as string "ABC" + 1=string "abc1," 1 + "ABC"=the string "ABC" 1,
The meaning of +=is accumulative, a +=b can be thought of as a=a + b

CodePudding user response:

Here to add a null string, meaning should be turn to digital string

CodePudding user response:

refer to fifth floor response: this is not a name
add a null string, here is let turn digital string

Because the output is defined as a String, and the count is defined as an int, here is the output for count++ results, and the results after count++ cannot be directly assigned to the output, so use an empty String for type conversion,

CodePudding user response:

1, +=: string and number, can put the number into a string,
2, count++, this should need not explain too much? Is the number 1 (but your code is=first, then add 1, is not the same as + + count order);
3, add a space finally ended,

CodePudding user response:

If this exam, the probability is in test your understanding of the priority, I write you see:
 public static void main (String [] args) {

String outPut="";
int count;

For (count=1; Count<=10; Count++) {
If (count==4) {
continue;
}
If (9) count=={
break;
}
/*
Here to add a "" belongs to type conversion, converted to a String type, a little suggestion, try not to use the ValueOf method of the String
After all, he is likely to be reported to the null pointer exception, in contrast, + "" better,
*/
The outPut +=count++ + ""

}
The outPut +="the outPut value is" + count;
System. The out. Println (" outPut the outPut value is: "+ outPut);
}

CodePudding user response:

, the continue is out of the current loop, this time has no effect on the subsequent, break is truncated, termination of circulation, jump out of the loop statement,
  • Related