0

This is what I got so far, ignore the fact that stuff is missing...

    if (fnum > snum && fnum > tnum && snum > tnum){
        System.out.println(fnum\n snum\n tnum);

So basically I want to have fnum snum and tnum all in a lane however I can't just do like:

System.out.println(fnum, snum, tnum);

because its giving me an error.

Any help? I can't figure this out at all and google searches are not being too helpful...

Devoted
  • 111
  • 9

3 Answers3

2

You need to concatenate the variables and strings:

System.out.println(fnum + "\n" + snum + "\n" + tnum);

or if you want cross platform new lines:

String ln = System.getProperty("line.separator"); // OS independent new line
System.out.println(fnum + ln + snum + ln + tnum);
Community
  • 1
  • 1
bcorso
  • 45,608
  • 10
  • 63
  • 75
0

try this

System.out.print(fnum);
System.out.println();
System.out.print(snum);
System.out.println();
System.out.print(tnum);

or you can also try System.out.println(fnum+"\n"+snum+"\n"+tnum);

System.out.println(); forces the next output to go to next line while in System.out.print the next output stays in the same line

Srinath Mandava
  • 3,384
  • 2
  • 24
  • 37
0

You can use printf

System.out.printf( "%s, %s, %s", fnum, snum, tnum );

And if you want each of the number on a new line, use:

System.out.printf( "%s\n, %s\n, %s\n", fnum, snum, tnum );

Refer to: java.io.PrintStream printf(String format, Object... args)

Ravinder Reddy
  • 23,692
  • 6
  • 52
  • 82