Tutorials Navigation

Tutorials :: New :: Popular :: Top Rated

Tutorials: 18,357 Categories: 12

Total Tutorial Views: 42,554,473

Java - Your first program

Tutorial Name: Java - Your first program  

Category: PC Tutorials

Submitted By: Kyle93

Date Added:

Comments: 1

Views: 2,207

Related Forum: PC Building Forum

Share:

Ok, well we will need a few things for this:
Java JDK - [ Register or Signin to view external links. ]
BlueJ - [ Register or Signin to view external links. ]
A Brain

Intalling
1) Intall JDK
2) Intall BlueJ - Make sure to pick the JDK

Programming
1) After installing, run BlueJ
2) New
[ Register or Signin to view external links. ]
3) Double click "Main"

Delete all thats there and copy this in
class Main
{
    public static void main( String args[] )
    {                   
        System.out.println("Hello World");
    }   
}


Now press "Compile" (Top left)

4) Now we run it
So, right click main and press "void Main"
[ Register or Signin to view external links. ]

You will get this
[ Register or Signin to view external links. ]

You have now created and run your first program.

Ok, a little about the code

class Main - This line is saying this is the class called "Main" this is used when you create programs with more classes.
{ - This is how we say whats in this section. We need to put these every time we doing somthing like this. For example an IF fig1
public static void main( String args[] ) - This is part of Java, the "public static" says that we are using a method that everyone can use and the "void" means that we wont return a value if this method is called.
{
System.out.println("Hello World"); - This is a pre made method to print out a value
}
}


fig1

if( x > y )
{
somecode
}

Ratings

Current rating: 4.00 by 15 users
Please take one second and rate this tutorial...

Not a Chance
1
2
3
4
5
6
7
8
9
10
Absolutely

Comments

"Java - Your first program" :: Login/Create an Account :: 1 comment

If you would like to post a comment please signin to your account or register for an account.

neboPosted:

ha, this was in a book I picked up at the library on java programming