Shop OBEX P1 Docs P2 Docs Learn Events
question about System.out.println — Parallax Forums

question about System.out.println

basicstampedebasicstampede Posts: 214
edited 2006-10-28 00:39 in General Discussion
The following code does not work:

int value;
System.out.println ("The value is ", value);

However, it works if I break into:

int value;
System.out.println ("The value is ");
System.out.println (value);

1.· println can only output 1 thing at a time?
2.· where is this stated in the Javelin manual?· (I don't believe this is a restriction of Java).

Thanks.

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-10-27 20:03
    You can best use the IDE help to find out quickly about classes and methods.
    Open help, packages, java.lang
    From Class summary, select System, then click out, then click PrintStream.
    That lists all methods for System.out
    Indeed, all these methods take only 1 argument.

    regards peter
  • bulkheadbulkhead Posts: 405
    edited 2006-10-28 00:39
    I've never seen it used with two parameters, but you can do this:
    System.out.println ("The value is " + value); //I'm not sure if you need to cast the value to (int)

    However that will use a lot more memory than if you put them on two lines as you have it now, because it will create a new string if you do it the one line way.
Sign In or Register to comment.