vendredi 27 mars 2015

Precedence in Strings in Java



what is the explanation of this precedence in strings in java?



public class PrecedenceInStrings {

public static void main(String[] args){

int x = 3;
int y = 5;

String s6 = x + y + "total";
String s7 = "total " + x + y;
String s8 = " " + x + y + "total";

System.out.println(s6 + "\n" + s7 + "\n" + s8);
}
}


output:


8total


total 35


35total




Aucun commentaire:

Enregistrer un commentaire