Java tutorial 1



  • I’ve been learning java for about two years now and I would like to share my personal experience with the community. So here is the first tutorial.

    In this we will be going over three different classes and how they work ofcourse we will be doing the helloworld or sup nigga’ classes.

    Here is the first class you will be learning:

    public class supnigga{

    public static void main(String[] args){
    System.out.println(“Sup, nigga!”);
    }
    }

    Very basic.

    The first thing you notice is the word public infront of the class definition and the main statement. This basically says other classes can access this method if it is private only the class the method is in can use it. If you know protected I shall go into that later.

    When defining a class there are 4 things you need:
    1: public/private/protected This class and other classes need to know how close they can go and if they can access methods.
    2: Class simple just put it. otherwise its not a class and it wont work.
    3: Name this can be anything without having non-alphabetical characters otherwise it will not work as intended.
    4: { this says anything inside these parthenses is in my class anything outside can fek off.

    so we know the class is there and we know how to make it so lets go over and put in our code.

    public class supnigga{

    This will not do anything and may even give you an error.
    The reason for this is that there is nothing in there and we havent said where the parenthses end the computer wont like this so you need to put } at the end of your classes. This includes methods otherwise if I have a method called bark and dont have the } then I have a method called meow and I try to call meow I will get an error.

    Here is the first and possibly most important method in java , without it the chances are you wont be able to run anything. public static void main(String[] args){}
    This is what the JAVAC (Java Compiler) looks for when trying to run your code, you don’t have it it wont run. You don’t need to know how it works its just there;

    so lets plug this in we have the class definition and our starting method.

    public class supnigga{

    public static void main(String[] args){
    }
    }

    Currently this does nothing but it doesnt give any errors and the compiler now knows that we mean bussiness.
    System.out.println(""); is a statement I personally use for debugging but is very useful if your making a console type game or just fucking around.
    This is a pre-built method already in java so you dont need to write anything other than it.
    System.out.println(""); is also a great example of three things in java that are essential if you’re going to go anywhere with it.

    1: the Dot Operator. This is like saying  Here is jim  he gives me candy if I ask him. its put like this  jim.askforcandy();    its calling a method in another class alot like asking for sweets of sex from another person.

    2: Arguments. Another essential feature of java this is the stuff in the brackets ("") this one takes a string argument which is basically a sentance. There are huge amounts of different variables that
    can be put as arguments from images to longs. The main ones we will use are ints and strings maybe more later. I will talk about this in a later tutorial.

    3: ; . This is fundamental without it your code will not run. It goes at the end of every line of code and the only exceptions are for methods , { } and class definitions.

    so lets just set our string to sup nigga for now.

    public class supnigga{

    public static void main(String[] args){
    System.out.println(“Sup nigga’ !!!”);
    }
    }

    Tada your first piece of code. When ran you should see it say in the console “Sup nigga’ !!!”.

    More to come if you want to see more.



  • I’ve been learning java for about two years now and I would like to share my personal experience with the community. So here is the first tutorial.

    In this we will be going over three different classes and how they work ofcourse we will be doing the helloworld or sup nigga’ classes.

    Here is the first class you will be learning:

    public class supnigga{

    public static void main(String[] args){
    System.out.println(“Sup, nigga!”);
    }
    }

    Very basic.

    The first thing you notice is the word public infront of the class definition and the main statement. This basically says other classes can access this method if it is private only the class the method is in can use it. If you know protected I shall go into that later.

    When defining a class there are 4 things you need:
    1: public/private/protected This class and other classes need to know how close they can go and if they can access methods.
    2: Class simple just put it. otherwise its not a class and it wont work.
    3: Name this can be anything without having non-alphabetical characters otherwise it will not work as intended.
    4: { this says anything inside these parthenses is in my class anything outside can fek off.

    so we know the class is there and we know how to make it so lets go over and put in our code.

    public class supnigga{

    This will not do anything and may even give you an error.
    The reason for this is that there is nothing in there and we havent said where the parenthses end the computer wont like this so you need to put } at the end of your classes. This includes methods otherwise if I have a method called bark and dont have the } then I have a method called meow and I try to call meow I will get an error.

    Here is the first and possibly most important method in java , without it the chances are you wont be able to run anything. public static void main(String[] args){}
    This is what the JAVAC (Java Compiler) looks for when trying to run your code, you don’t have it it wont run. You don’t need to know how it works its just there;

    so lets plug this in we have the class definition and our starting method.

    public class supnigga{

    public static void main(String[] args){
    }
    }

    Currently this does nothing but it doesnt give any errors and the compiler now knows that we mean bussiness.
    System.out.println(""); is a statement I personally use for debugging but is very useful if your making a console type game or just fucking around.
    This is a pre-built method already in java so you dont need to write anything other than it.
    System.out.println(""); is also a great example of three things in java that are essential if you’re going to go anywhere with it.

    1: the Dot Operator. This is like saying  Here is jim  he gives me candy if I ask him. its put like this  jim.askforcandy();    its calling a method in another class alot like asking for sweets of sex from another person.

    2: Arguments. Another essential feature of java this is the stuff in the brackets ("") this one takes a string argument which is basically a sentance. There are huge amounts of different variables that
    can be put as arguments from images to longs. The main ones we will use are ints and strings maybe more later. I will talk about this in a later tutorial.

    3: ; . This is fundamental without it your code will not run. It goes at the end of every line of code and the only exceptions are for methods , { } and class definitions.

    so lets just set our string to sup nigga for now.

    public class supnigga{

    public static void main(String[] args){
    System.out.println(“Sup nigga’ !!!”);
    }
    }

    Tada your first piece of code. When ran you should see it say in the console “Sup nigga’ !!!”.

    More to come if you want to see more.


  • Administrators

    are you mentally retarded?


Log in to reply
 

Looks like your connection to NoXiousNet was lost, please wait while we try to reconnect.