Basic JAVA Programming - Guest Tutorial
Hello Guest!
As of creating this page for you we have a total of 468 members, enjoy the full quality of this site and register an account now. You'll be able to submit your self-written tutorials, use the forum to it's full potential, add messages to the shoutbox, comment on tutorials / blog posts and vote in the current webpoll.
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: