Results 1 to 4 of 4

Thread: Writing In Java

  1. #1
    Join Date
    Feb 2007
    Posts
    601
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Writing In Java

    Hello all,

    I am a complete begginner to java and don't know the first thing about it ...
    If I wanted to write Hello Juice Bomber in a java program how would i do it/what's the code???

    Thanks

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    What sort of a Java program?

    To write it to the console,
    Code:
    class Hello {
      public static void main(String[] argv) {
        System.out.println("Hello Juice Bomber");
      }
    }
    Or with a Swing GUI:
    Code:
    import java.swing.JFrame;
    import java.swing.JLabel;
    import java.swing.JPanel;
    
    class Hello extends JFrame {
      public Hello() {
        super("Hello");
        setSize(150, 100);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        ((JPanel)getContentPane()).add(new JLabel("Hello Juice Bomber"));
        setVisible(true);
      }
    
      public static void main(String[] argv) {
        new Hello();
      }
    }
    Or as an applet:
    Code:
    import java.swing.JApplet;
    import java.swing.JLabel;
    import java.swing.JPanel;
    
    class Hello extends JApplet {
      public void start() {
        ((JPanel)getContentPane()).add(new JLabel("Hello Juice Bomber"));
      }
    }
    Last edited by Twey; 02-25-2007 at 04:09 PM.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Mar 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Talking Simple java program

    class Simple
    {
    public static void method()
    {
    System.out.println("Hello Juice Bomber");
    }
    public static void main(String Str[])
    {
    Simple.method();
    }
    }

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Um... that's nice?
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

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