Concatenation
int sum = 123;
double avg = 1.23;
System.out.println("Sum: " + sum + " Avg: " + avg + ".");
Concatenation
int sum = 123;
double avg = 1.23;
System.out.println("Sum: " + sum + " Avg: " + avg + ".");
Concatenation
int sum = 123;
double avg = 1.23;
System.out.println("Sum: " + 123 + " Avg: " + avg + ".");
Concatenation
int sum = 123;
double avg = 1.23;
System.out.println("Sum: " + 123 + " Avg: " + avg + ".");
Concatenation
int sum = 123;
double avg = 1.23;
System.out.println("Sum: " + 123 + " Avg: " + 1.23 + ".");
Concatenation
int sum = 123;
double avg = 1.23;
System.out.println("Sum: " + 123 + " Avg: " + 1.23 + ".");
// Sum: 123 Avg: 1.23.
Formatted Strings
int sum = 123;
double avg = 1.23;
String name = "Student";
String output = "%s: Score: %5d Average: %8.4f.";
System.out.println(String.format(output, name, sum, avg));
Formatted Strings
int sum = 123;
double avg = 1.23;
String name = "Student";
String output = "%s: Score: %5d Average: %8.4f.";
System.out.println(String.format(output, name, sum, avg));
Formatted Strings
int sum = 123;
double avg = 1.23;
String name = "Student";
String output = "%s: Score: %5d Average: %8.4f.";;
System.out.println(String.format(output, name, sum, avg));
// "%s: Score: %5d Average: %8.4f."
Formatted Strings
int sum = 123;
double avg = 1.23;
String name = "Student";
String output = "%s: Score: %5d Average: %8.4f.";
System.out.println(String.format(output, name, sum, avg));
// "%s: Score: %5d Average: %8.4f."
Formatted Strings
int sum = 123;
double avg = 1.23;
String name = "Student";
String output = "%s: Score: %5d Average: %8.4f.";
System.out.println(String.format(output, name, sum, avg));
// "Student: Score: %5d Average: %8.4f."
Formatted Strings
int sum = 123;
double avg = 1.23;
String name = "Student";
String output = "%s: Score: %5d Average: %8.4f.";
System.out.println(String.format(output, name, sum, avg));
// "Student: Score: %5d Average: %8.4f."
Formatted Strings
int sum = 123;
double avg = 1.23;
String name = "Student";
String output = "%s: Score: %5d Average: %8.4f.";
System.out.println(String.format(output, name, sum, avg));
// "Student: Score: 123 Average: %8.4f."
Formatted Strings
int sum = 123;
double avg = 1.23;
String name = "Student";
String output = "%s: Score: %5d Average: %8.4f.";
System.out.println(String.format(output, name, sum, avg));
// "Student: Score: 123 Average: %8.4f."
Formatted Strings
int sum = 123;
double avg = 1.23;
String name = "Student";
String output = "%s: Score: %5d Average: %8.4f.";
System.out.println(String.format(output, name, sum, avg));
// "Student: Score: 123 Average: 1.2300."
Formatted Strings
int sum = 123;
double avg = 1.23;
String name = "Student";
String output = "%s: Score: %5d Average: %8.4f.";
System.out.println(String.format(output, name, sum, avg));
// "Student: Score: 123 Average: 1.2300."
Formatted Strings
int sum = 123;
double avg = 1.23;
String name = "Student";
String output = "%s: Score: %5d Average: %8.4f.";
System.out.println(String.format(output, name, sum, avg));
// Student: Score: 123 Average: 1.2300.