Basic JAVA Programming - Guest Tutorial
Hello Guest!
Interested in advertising? Well, we have been in the Tutorial field for quite some time now (4 years to be exact). We receive ±1300 unique visitors per day which totals a monthly average of 39000 unique visitors, so advertising with us will definitely get your site exposed to many tutorial lovers. Head on over to the Advertise page so you can familiar yourself with more details.
Info & Save:
Category:
JavaDate added:
15-10-07Level:
BeginnerAuthor:
Cristian @ GFX ClassSave to:
Delicious
Digg
Stumbleupon Intro:
In this guest tutorial you'll learn how to create a simple java program that will show us a sentence, first I`ll write the code and then explain what it does.
Step 1:
The code:
//Example
public class Ex1 {
public static void main(String args[] )
{
System.out.println( "Welcome to Java Programming!" );
}
}
public class Ex1 {
public static void main(String args[] )
{
System.out.println( "Welcome to Java Programming!" );
}
}
Explanation of the code:
- //Example: Comments, just like in html, php, etc.
- public class Ex1: Every Java code begins with defining a class. Every class has an unique name and the source code for a class must be saved in a source file which has the same name as the class. ( i.e. Ex1 )
- public static void main( String args[] ): Classes contains both data and methods. The data can be numbers, text or different objects. Ex1 class has a single method called main. The main method of an object is the point from where the Java Virtual Machine (JVM) begins the execution of a program. An object can have many methods, but the Java Virtual Machine (JVM) must know the starting point of the program. This is a basic signature which the inventors of JAVA chose.
- System.out.println( "Welcome to Java Programming!" );: The object Ex1 sends to the System.out object a message in which it tells it to show us using the println method what we have put in the round brackets in our case the Welcome to Java Programming sentence.
Java result screenshot: