Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Java Tutorial

  1. #1
    Senior Member
    Join Date
    Sep 2001
    Posts
    193

    Post Java Tutorial

    Here is a little tutorial in Java for people who are insterested in programming. I love programming and would love to help teach anyone who is insterested in learning. So here is a program for beginners to learn. "Remember all programmers learn by mimicking what other programmers have done before them."


    // A easy first program

    public class Welcome {

    public static void main( String args[] )

    {

    System.out.println( "Welcome to AntiOnline!" );

    }

    }



    Now i will break it down:

    Line 1: // is just a comment, programmers insert comments for program readability;
    Comments are ignored by the java complier.

    Line 2: public class Welcome {

    /*This begins a class definition for "Welcome". Every program in
    java consists of at least one class definition that is defined by
    the programmer. Notice Welcome is what the programmer names it.
    I could of even put " public class AntiOnline { ". The keywords
    " public class " remain a consant for now. the {
    begins the body of the class*/

    Line 3: public static void main ( String args[] )
    /*is part of every java application
    Application begin excuting at main.
    The parentheses after main indicate that main is
    is a building block called a method. Methods are
    able to perform tasks and return information when
    they complete there task. The void keyword
    indicates that the method will perform a task but,
    will not return any information when it completes
    its task.*/

    Line 4: { // begins the body of the method definition

    Line 5: System.out.println( "Welcome to AntiOnline!" );
    /*This is self explanatory but, i
    will go indept. This instructs
    the computer to perform an action. The computer will
    print out the string of character between the
    quotation marks. System.out is known as the standard
    output. The entire line, including System.out.println,
    its arugment in the parnetheses and the semicolon, is
    called a statement. A semicolon is a statement terminator.*/


    Line 6: } // ends method main()

    Line 7: ) // ends class Welcome

    The output of this program is:

    Welcome to AntiOnline!

    I suggest you learn C++ first
    because java is built on top
    of C++. But you can learn java first if that is what you want,
    its just easier if you know C++.

    If people like this tutorial i will be glad to go a step farther.

    Enjoy all!!
    [shadow]l3aDmOnKeY[/shadow]

  2. #2
    oblio
    Guest
    Java is a language completely independant of C++. It was not built to model C++ or be like C++ in any way.

    Not all java applications have a main method, since java programs are meant to be built modularly, many packages make use of methods that must be explicitly called. Also, Applets and Servlets both do not have a main method.
    You also have failed to explain that the argument String args[], which in Java should really be written String[] args, since an array is an object, holds command line arguments delimited by a space and beginning at unlike C++, index=0.

    System.out is not the standard output, the out is a field of the System object that is a part of the Object package. out is of datatype PrintStream and therefore is capable of output. This PrintStream happens to wrap the standard output so is therefore capable of printing to the screen.

    Oh and knowing C++ will not enhance your ability to program java, it will only enhance your ability to adapt to java's syntax. Java is very different from C++ as many articles explain in detail. If anything C++ is harder than java.

    This is hardly a tutorial as is of no use to anyone wanting to learn Java. I suggest a visit to the tutorials on java.sun.com.

  3. #3
    Senior Member
    Join Date
    Oct 2001
    Posts
    638
    This is in responce to oblio's last post:

    Java is a language completely independant of C++. It was not built to model C++ or be like C++ in any way.
    While java is an language independant of c++, Java's syntax was deliberately modelled on C/C++.

    Not all java applications have a main method, since java programs are meant to be built modularly, many packages make use of methods that must be explicitly called. Also, Applets and Servlets both do not have a main method.
    You also have failed to explain that the argument String args[], which in Java should really be written String[] args, since an array is an object, holds command line arguments delimited by a space and beginning at unlike C++, index=0.
    Very valid point!

    Oh and knowing C++ will not enhance your ability to program java, it will only enhance your ability to adapt to java's syntax. Java is very different from C++ as many articles explain in detail. If anything C++ is harder than java.
    Since C++ and Java are both OOP languages, they use the same underlying concepts. If you've already learnt C++ (or any OOP language) it makes it heaps easier to learn another OOP language. There are differences but there are a lot more similarities. But I do concede that C++ is probably harder than Java (Multiple Inheritance, ARRHH!)

    This is hardly a tutorial as is of no use to anyone wanting to learn Java. I suggest a visit to the tutorials on java.sun.com.
    Sure the tutorial isn't Java Unleased but it's nice to see some people are making an effort to post security related information. At least give him that much.

    =) Good post though
    OpenBSD - The proactively secure operating system.

  4. #4
    Senior Member
    Join Date
    Sep 2001
    Posts
    193
    oblio point taken but:


    This is a beginning tutorial not a whole expantion. I am not to applets in this tutorial. And yes Applets have methods example: public void paint ( Graphics g )

    You also have failed to explain that the argument String args[], which in Java should really be written String[] args, since an array is an object
    First I am not expaning that far and second ( String args[] ) is correct

    If anything C++ is harder than java.
    maybe to you!


    enhance your ability to adapt to java's syntax.
    WOW that was correct; good job

    This is hardly a tutorial as is of no use to anyone wanting to learn Java. I suggest a visit to the tutorials on java.sun.com.
    I suggest you take a java class yourself


    This was a simple program with a start in the knowagle of knowing whats going on in the program. Remember what I said
    all programmers learn by mimicking what other programmers have done before them
    This was a SIMPLE PROGRAM with little text in it, NOt a freaking 8 week class as i guess you were expecting
    [shadow]l3aDmOnKeY[/shadow]

  5. #5
    oblio
    Guest
    I do not see how a Java course would be beneficial to me due to Sun's tremendous documentation and my experience as a professional java programmer

  6. #6
    Senior Member
    Join Date
    Sep 2001
    Posts
    193
    What ever "Floats your boat oblio" I am not posting this as a point for battleing wits with you.

    and yes I my self is a C++ and java programmer for the US Army.
    [shadow]l3aDmOnKeY[/shadow]

  7. #7
    oblio
    Guest
    oh wow the US Army should I be impressed that you have sold your soul to imperialism . I bet you make accounting software.

  8. #8
    Senior Member
    Join Date
    Aug 2001
    Posts
    168
    it's a good tutorials for beginers. a nice place to begin with and love programming. i do love c/c++ than java, and do like perl scripts than java scripts. but i really admire the complicated syntax of java. it some sort of cool tweaking of c/c++ programming. there is only slight difference in c/c++ and java but still i prefer the old c programming becuase of the sysntax.
    in scripting i usually use java if and only if i edit some sort of cgi apps rather than choosing perl in it. java scripts are very handy and not so complicated. perl is not that complicated but rather i choose it in scripting while im in my box (running some sort of *nix).
    it is a good language and lots of people get interested with it. i hope you will make more tutorials and more power.
    \"The more you ignore me... the closer i get!\"

  9. #9
    I think it's good people try to post some tutorials about programming, but a simple post won't cover all the things it should.
    Could be good for beginners, but I think it's better to go to Sun's site and see the tutorials, they are very complete.
    But, good post anyway man.
    \"The best place to find a helping hand is at the end of your own arm...

  10. #10
    Senior Member
    Join Date
    Sep 2001
    Posts
    535
    hey badmonkey one very important thing..and that is...the java file is saved with extension .java but the name of the file and the main class name should be same...
    as java is case sensitive...
    for e.g

    public class Antionline {

    public static void main(String[] args){
    System.out.println("Welcome to antionline");
    }
    }

    if this is the program ...then it should be saved as Antionline.java

    moreover u have to set java path to your directory to compile it
    which u can do it like this :-

    c:\> set classpath = c:\jdk1.3\bin; <enter>

    when the classpath is set then one has to compile the programme like this :-

    c:\> javac Antionline.java

    when this gets compiled...then to run it...like this :-

    c:\> java Antionline

    and the output will look like this..

    c:\> java Antionline
    Welcome to Antionline

    c:\>


    well so that is it...but anyway...it was a real good post...and an introduction to java for newbies...

    keep up the good work..

    intruder...
    A laptop, internet connection and beer.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •