• Log in or sign up for an account here: https://www.sythe.org/login

Simple Java Guide for New Learners

Jokerz

Forum Addict
Joined
Apr 24, 2008
Sythe Gold
0
Messages
610
Location
Australia
Simple Java Guide for New Learners
Hey folks. I'll give you a simple Java guide to see if you are interested in Java, I myself is learning Java slowly ;)

What you need:

- JDK 6 (Download Here: http://java.sun.com/javase/downloads/index.jsp)
- Command Prompt
- Notepad
- A Brain
- A keyboard

Shall we start?

I've decided to add a block comment at the start of the program, It will help people know what the program is.

A block comment looks like this.

Code:
/* Hello Rawr, by Vinny
           *
          /*

That line will be ignored by the Java compiler (Javac)

Next we shall identify the class we want to make. So open up Notepad and type this in.

Code:
class HelloRawr {

As you can see we are calling the class to be HelloRawr, When we compile this later it will make it HelloSythe.

Under it you may put this.

Code:
//This is a single line comment. etc...

This is the same as block comment but for just one line only.

Now time for the main coding.

Under the single line comment put:

Code:
public static void main(String args[]){

Woah! What was that?

Let me explain in small parts.

  • Public: This means its going to be a public class its public
    Static: This allows main() to happen. Which is shown here as (String args[])
    void: This will not return any values we set.
    main: This is calling main (used for javac)
    String: This is a readable language by humans.
    args: Calling an argument forth
    []: Random
    {: Clossing the function
Now under that code add this:

Code:
System.out.println("Hello Sythe");

This code will tell the program to print some words in the bracket. (Use if you want to print word).

Your final code should look like this.

Code:
/* Hello Rawr
           *
          /*
              class HelloRawr {
           //Random comment lol
          public static void main(String args[]) {
          System.out.println("Hello Rawr");
        {
      {

Time to compile this bitch.

Save the file as HelloRawr.java in C:\Java

Now open Command Prompt and type in this.

cd C:\Java

(This changes the Directory to C:\Java)

Now type this: javac HelloRawr.java

Now check the Java file and there should be HelloRawr.class

Now open it and it should display 'Hello Rawr'

Congrats, You have learnt the first step to Java.
 
Simple Java Guide for New Learners
Nice and simple! Youve got me interested in java now but I wasnt before reading
 
Simple Java Guide for New Learners
very nice guide.. i've never really knew how to code with java but now i know some basics :) thanks
 
Simple Java Guide for New Learners
Nothing is explained very well. If people had no idea what Java was, they would still be lost.

main is java's main method, the method that is run when you start the program

Public: Public method
Static: Makes it so you do not need to create an object from the method before using... ( or sumthing likr that)
void: This will not return any values we set.
main: what javas main method is called
String: a group of letters... Like this... :/
args: advanced shit, you won't use for awhile.. to lazy to tell you
[]: it means it an array
{: starting the method... :/

} end of method. :/
 
Simple Java Guide for New Learners
Nothing is explained very well. If people had no idea what Java was, they would still be lost.

main is java's main method, the method that is run when you start the program

Public: Public method
Static: Makes it so you do not need to create an object from the method before using... ( or sumthing likr that)
void: This will not return any values we set.
main: what javas main method is called
String: a group of letters... Like this... :/
args: advanced shit, you won't use for awhile.. to lazy to tell you
[]: it means it an array
{: starting the method... :/

} end of method. :/


Sigh..

Public isn't a method, it's an access level. It allows it to be inherited, while protected can't be overriden, and private cannot be inherited.

A void is a method that won't return any values (you got most of that right).

A string isn't just a group of letters. A string can be a single word, a group of phrases, a group of letters, or a group of numbers. All strings are in between quotation marks.

Args is short for argument.
 
Simple Java Guide for New Learners
Nothing is explained very well. If people had no idea what Java was, they would still be lost.

main is java's main method, the method that is run when you start the program

Public: Public method
Static: Makes it so you do not need to create an object from the method before using... ( or sumthing likr that)
void: This will not return any values we set.
main: what javas main method is called
String: a group of letters... Like this... :/
args: advanced shit, you won't use for awhile.. to lazy to tell you
[]: it means it an array
{: starting the method... :/

} end of method. :/

this clears my problem up with what "static " does.
i can do public static void can i?
 
Simple Java Guide for New Learners
well put together thx
 
Simple Java Guide for New Learners
you should include class structures, what IDE do you recommend for java?
 
Simple Java Guide for New Learners
Quite intresting, i always wanted to lern java but i just don't have the time.
 
Simple Java Guide for New Learners
to complicated for me, maybe ill try in 2 years lol (:
 
Simple Java Guide for New Learners
/* Hello Rawr
*
/*
class HelloRawr {
//Random comment lol
public static void main(String args[]) {
System.out.println("Hello Rawr");
{
{
Sadly compiling this fails because a multi-line comment is meant to be closed with "*/" and not "/*"
(This changes the Directory to C:\Java)

Now type this: javac HelloRawr.java
This will not work for the MAJORITY of people because the average user won't have the Java environment variables setup and therefore will have to specify the exact path to "javac" for Windows to find it (C:\Program Files\Java\Jdk[...]\bin\javac).
Public: This means its going to be a public class its public
Static: This allows main() to happen. Which is shown here as (String args[])
void: This will not return any values we set.
main: This is calling main (used for javac)
String: This is a readable language by humans.
args: Calling an argument forth
[]: Random
{: Clossing the function
The public modifier allows for something to be accessed throughout the program.
The static modifier allows for members/methods to be invoked without creating any objects.
Void means that something will not return a value PERIOD.
The main function of a java program is called as soon as you run the program. Without one a java program isn't executable.
Strings are objects defined by the String class in Java that can hold a sequence of characters by putting double quotes around some text.
Args (short for arguments) are string values you can pass to your program when you first execute to add aditional functionality or specify a certain way you want it to run.

From your compile errors and such basic compiling instructions it's obvious you aren't very far into the language at all, let alone ready to write a guide to teach others how to start off. Something like this can only give others bad notions/habits in regards to the language and programming itself or put them off it completely when they notice it doesn't work as planned. In the future stick to what you do know, when it comes to writing guides.
 
Simple Java Guide for New Learners
wow, i was thinking about getting into java...but im in over my head, thanks anyway :p
 
Simple Java Guide for New Learners
Good Guide for idiots who keep posting asking for help. Two thumbs up:)
 
Simple Java Guide for New Learners
Most of this stuff is wrong, please learn more before you attemp to make a tutorial. It is misleading to people trying to learn java...
 
Runescape Gamblingrunescape gambling
Back
Top