Basic JAVA Programming - Guest Tutorial



Info & Save:

Category:
Java
Date added:
15-10-07
Level:
Beginner
Author:
Cristian @ GFX Class
Save 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!" );
}
}

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:
Basic JAVA Programming

Shoutbox
Celox
The brand new site is up and running! There changed a lot around here, so many that I'll be posting a descriptive post on the blog tomorrow Happy I hope you all like the new version's redesign, the new features and what not. There are still some minor bugs those need fixing but I'll get on that in the very near future.
draw_dogs_101
Er... Wierd dogs msg me..
Celox
Hey Hey!
maycute_25
helow to celoxdesign
Celox
Added some new cool text effects, check 'em out! Especially check out the 3D Bulge text effect, it's again one of the best text effect tutorials on the web.
Celox
200 members \o/ let's get drunk! Happy
Celox
I've replied in the critique my graphics thread
Matt
Look at my spider man
Webpoll
Did the site improve with its new update?
Hell yeah!
Nah, I don't think so..
No idea, this is my first time here

Advertisements