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
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...
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"...
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.
Originally Posted by nighil
my problem was with "+".now got the answer.thanks for ur interest
thank ypu for your explanation.It helped me a lot..Now no problem with prntln