Results 1 to 6 of 6
  1. #1
    nighil is offline Newbies
    Join Date
    May 2011
    Posts
    5
    Rep Power
    0

    Default System.out.prntln

    System.out.println("\nArea "+area);
    cab anyone please explain this syntax and the use of "+" in this.I also want to know
    in the statement
    public static void main(String args[])
    what is the use of the parameter passed String args[] and use of static.Is it compulsory to use these

  2. #2
    Join Date
    May 2011
    Location
    Herentals, Belgium
    Posts
    14
    Rep Power
    0

    Default

    System.out.println("\nArea"+area); :

    The \n is an escape character, this will print an "empty" line first. the rest will be printed on the next line. "\nArea" is a string (ignore the \n), so ist quite obvious that this wil be printed to screen the way you see it.
    The +area part: the + means you want to add something after the "\nArea", the thing that will bee added will be whatever is in the area-variable.
    f.i: int area = 32 , this will get you the output "Area32" (note that it will be pasted right after the string so if you want "Area 32" you wil need to type: System.out.prinln("\nArea "+area); (note the extra space after "Area".
    Also the ln in println makes the cursor go to a new line after it has printed its contents

    You got any help from this? I know I sck at explaining things...

    Peace
    Enjoy your milk!! :cool:

  3. #3
    Join Date
    May 2011
    Location
    Herentals, Belgium
    Posts
    14
    Rep Power
    0

    Default

    Static means that you do not have to initialize your class before you can use the method.

    String[] args is an array of strings, which you can fill before you run your program. For example, if you use the command line to run your program : java MainProgram , this will let you run the program with an empty args array. If you use java MainProgram hello, the first element og the args array will be "hello"...

    Peace
    Enjoy your milk!! :cool:

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,854
    Rep Power
    19

    Default

    Quote Originally Posted by nighil View Post
    System.out.println("\nArea "+area);
    cab anyone please explain this syntax and the use of "+" in this.I also want to know
    in the statement
    public static void main(String args[])
    what is the use of the parameter passed String args[] and use of static.Is it compulsory to use these
    You said in your other thread you know C and C++ so I find it hard to believe you don't know the answer to most of this already, or at least guess at it.

  5. #5
    nighil is offline Newbies
    Join Date
    May 2011
    Posts
    5
    Rep Power
    0

    Default

    my problem was with "+".now got the answer.thanks for ur interest

  6. #6
    nighil is offline Newbies
    Join Date
    May 2011
    Posts
    5
    Rep Power
    0

    Default

    thank ypu for your explanation.It helped me a lot..Now no problem with prntln

Similar Threads

  1. Java System
    By janz_23 in forum Enterprise JavaBeans (EJB)
    Replies: 1
    Last Post: 10-05-2010, 01:21 PM
  2. System Tray
    By 67726e in forum AWT / Swing
    Replies: 8
    Last Post: 08-12-2010, 04:21 PM
  3. Replies: 3
    Last Post: 02-07-2010, 08:34 PM
  4. System Tray
    By JavaLerner in forum New To Java
    Replies: 2
    Last Post: 07-13-2008, 08:25 AM
  5. Password System help
    By quickfingers in forum New To Java
    Replies: 1
    Last Post: 06-23-2008, 06:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •