Back to questions
JuniorTheoryCommon
What does the program print?
public class Main {
public static void main(String[] args) {
System.out.print(1);
System.out.print(2);
System.out.println(3);
}
}123
- Expecting
1 2 3:printadds neither a space nor a line break, so the values stay glued into123untilprintlnends the line. - Expecting
6: nothing adds the numbers up;print(1)andprint(2)each print their own value, andprintln(3)prints3.
- What does
System.out.println()with no argument print? - How would you print
1 2 3on one line, with spaces between the numbers?