Results 1 to 7 of 7

Thread: New to Java Programming

  1. #1
    Senior Member Falcon21's Avatar
    Join Date
    Dec 2002
    Location
    Singapore
    Posts
    252

    New to Java Programming

    I will be enrolled into a IT course in the late June. I will be learning a lot of things that I have never heard before. One of them is Java programming. I am just started learning VB on my own and have no experience in other languages. But before I get into the course, I hope to know something about Java. Does anyone here know where can I get started with Java? Any books to recommend for beginner? What is Java used for? Most importantly, is it easy to learn :P?
    Thanks!



  2. #2
    AntiOnline n00b
    Join Date
    Feb 2004
    Posts
    666
    Hi

    What is Java used for? Most importantly, is it easy to learn :P?
    Java is used for developing two types of Applications

    • Stand-Alone Applications
    • Web Base Applications (also Called Applets)


    Stand Alone applications are like any other Application you use, e.g. notepad , Wordpad any thing. It runs on it's own.

    Applets is a Small program that is embedde into the Web page it needs a HTML page to run it can't run on its own.

    There are many GUi Application development Programs Available today that make it easier for you to program in java. They provide you with the WYSIWYG interface, But i am a littel old fashioned and still use notepad, and i suggest to start of use notepad or orher editor to code small programs in java. It's a Object Oriented Programming Language Just like C++. Not that Difficult to pick up.

    Java 2 Complete Refrrence is a very good book i still refer it. I covers almost Application Programming in detail it also tuches Applets but does not go indepth.

    Download JDK if you haven't Already http://java.sun.com/

    And Heres Something to get You started

    The Famous Hello World Program The First Program of Every Language

    Applet
    Code:
    /*<html>
    <APPLET CODE="HelloWorld.class" WIDTH=150 HEIGHT=25>
    </APPLET>
    </HTML>*/
    
    import java.applet.Applet;
    import java.awt.Graphics;
    
    public class HelloWorld extends Applet {
        public void paint(Graphics g) {
            g.drawString("Hello world!", 50, 25);
        }
    }
    oooo Boy It's always been exciting when it Runs the very First

    Grrrrrrrrrrrrrr Go boy Go

    You will find every thing you need to get Starte Here http://java.sun.com/docs/books/tutorial/

    --Good Luck--

  3. #3
    Banned
    Join Date
    Aug 2003
    Posts
    130
    I wouldnt recommend using notepad as a beginner. Use JCreator (http://jcreator.com/) it offers syntax highlighting, auto indentation and it makes compiling and running applications/applets a lot easier.

    It is, in my opinion, ONE of the easiest languages to learn. It is a cleaned up version of c++ (sort of). It leaves out some of the harder concepts that are in c++. Plus it's an OOP (Object Oriented Programming) language which is one of its main features.

    Here is an application version of the Hello World program.
    Code:
    //HelloWorld.java      <-comment
    
    public class HelloWorld 
    {
         public static void main(String args[])
         {
              System.out.println("Hello World!");        //Prints Hello World to the output device
         }
    }
    oooo Boy It's always been exciting when it Runs the very First
    Like gettin high, getting drunk or doin it theres nothin like your first time.

  4. #4
    Senior Member
    Join Date
    Oct 2003
    Posts
    234
    I started with VB myself, and when I decided to try java I found it very different, not only because of it's C-style syntax, but it really forces you to be object oriented, something you don't really see in VB (at least VB 6 and under ). Creating a GUI in java is really different, so I'd get a book or two on that if you intend on writing graphical applications rather than console-based ones. However, it's platform independance and power make it a much better language to use than VB, IMHO.

  5. #5
    Junior Member
    Join Date
    Oct 2002
    Posts
    2

    Interfaces

    Try to use interfaces from the start, they will make your life easier. Basicly, a interface is a list of methods (functions) that the class using the interface will have to implement. if a class uses a certain interface, you know that the class supports the methods in it.

    For example, if you have this interface in a file named Person.java:

    interface Person
    {
    public void setName(String name);
    public String getName();
    public void setPhoneNumber(int phoneNumber);
    public int getPhoneNumber();
    }

    ... and this code in another file named PersonImpl.java...

    import java.io.*;

    public class PersonImpl implements Person
    {
    private String name;
    private int number;

    public void setName(String name){
    this.name = name;
    }

    public String getName(){
    return name;
    }

    public void setPhoneNumber(int phoneNumber){
    this.number = phoneNumber;
    }


    public int getPhoneNumber(){
    return number;
    }

    public String toString(){
    return name + "\t" + number;
    }
    }


    ... you have yourself a nice program to start with. This example uses object oriented principles with get/set methods for the data member variables (name and number).

    You also need a Main.java file where the execution can begin:

    public class Main
    {
    public static void main(String[] args)
    {
    Person p = new PersonImpl();
    p.setName("Bill Gates");
    p.setPhoneNumber("666");
    }
    }

    The code above creates a object from the PersonImpl class (which uses the interface Person). It then uses the methods of the class to put some data into the object.

    Anyways, good luck with your programming. I think Java is a good place to start.

    /
    / 0x0

  6. #6
    Banned
    Join Date
    Aug 2003
    Posts
    130
    Try to use interfaces from the start, they will make your life easier.
    I disagree interfaces are too advanced for a beginner. Falcon21 should learn the basics like i/o, operators, conditionals, loops, etc...

  7. #7
    Originally posted here by mikem0327
    I disagree interfaces are too advanced for a beginner. Falcon21 should learn the basics like i/o, operators, conditionals, loops, etc...
    Yeah, but things like operators, loops, conditionals etc. are exactly that: "basics". Yes, he is new to the language, but these basics extend through most languages. Things like interfaces should be learned, they are more a part of java.

    Java is a cleaned up version of c++ and is meant to be a lot more secure. Where in c++ you can get away with a lot of stuff, java will not let you. Sometimes this can be benificial, other times you will find yourself saying..."man, i could do this so much faster in c++".

    The java complier at times can be very frustrating, especially if working in windows. If you accidentaly write yourself an infinite loop, and dont shut off the compiler fast enough, you will find yourself doing a ton of ctrl-alt-deletes.

    In my opinion, the worst thing about java is (and i may get bashed for saying this) the swing/awt packages. Creating gui's is so frustrating, much like coding html for 4.0 broswers. Where is the css equivalent for Java??? I have a love/hate relationship with java. I cannot wait till i become fluent in perl.

    Good luck with it though. I hope you enjoy your class, come here if you have any questions.
    severe limitation

Posting Permissions

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