Now, as i have told you that i will discuss the code given in my last post :
JAVA Tutorial : Beginner
JAVA Tutorial : Beginner
So now we will start with that :
class abc
{
public static void main (String[ ] p) //This the basic Syntax to declare main.
{
System.out.print("yeah we did it...this is my first java program");
}// ends the main method.
}// ends the class.
class = Keyword to declare the class in JAVA. Everything resides inside the Class in JAVA.
abc = Name of the class .
{ = Curly brace showing the start of abc class
public = It is used so that it can be accessed by everyone(by everyone means different classes and objects).
Static = later guys..we'll talk about it later.
void = It represents return type of main.
main = the name of method,compiler starts compiling from main method. so we must use main method.
(String [] p) Used to initiate main method using string with arguments.
System.out.print = This says print to standard output .
;= every statement must end with semicolon.
Now lets make something new :
System.out.println("yeah print things in new line");
Now new code looks like this :
class abc
{
public static void main (String[ ] p)
{
System.out.println("yeah print things in new line");
System.out.print("yeah we did it...this is my 2nd java program");
}
}
And output :
Thus. println makes the things to print in the next line as it shown in above snap.
So, this is it.
Please put your queries down there in the comment box.
Thank you.
Link to NEXT POST : JAVA TUTORIAL : 3 (FEATURES OF JAVA AND NAMING CONVENTIONS)
{
public static void main (String[ ] p) //This the basic Syntax to declare main.
{
System.out.print("yeah we did it...this is my first java program");
}// ends the main method.
}// ends the class.
Now new code looks like this :
class abc
{
public static void main (String[ ] p)
{
System.out.println("yeah print things in new line");
System.out.print("yeah we did it...this is my 2nd java program");
}
}
And output :
Thus. println makes the things to print in the next line as it shown in above snap.
So, this is it.
Please put your queries down there in the comment box.
Thank you.
Link to NEXT POST : JAVA TUTORIAL : 3 (FEATURES OF JAVA AND NAMING CONVENTIONS)
Comments
Post a Comment