Thread: My learning experiances

Page 1 of 3 123 LastLast
Results 1 to 10 of 22
  1. #1 My learning experiances 
    Dev.
    Guest
    I'm making this thread to see how far i can get into java. So far i made this neat little program that counts to 100.

    Spoiler for Click for code:
    Code:
    public class one {
    	public static void main(String[] args) {
    		for(int i = 0; i <= 100; i++) {
    			System.out.println(i);
    		}
    	}
    }
    // Use a bracket after the loop (proper use)
    Update 1: The program does work.


    I know it is not hard, but this is my first time using java. I'm pretty excited about it.


    2nd project.
    Spoiler for Click for code:

    Code:
    public class Greeter {
    
    	public static void main (String [] args) {
    		Hello myHelloObject = new Hello();
    		myHelloObject.sayHello();
    	}
    }
    And

    Code:
    // This creates a box with the words hello world in it.
    
    import javax.swing.JOptionPane;
    
    public class Hello {
    	public void sayHello() {
    		JOptionPane.showMessageDialog(null,
    				"Hello, World!", "Greeter",
    				JOptionPane.INFORMATION_MESSAGE);
    	}
    }


    I ran it and it makes a box and says the words Hello, World!


    P.S. if you guys want to give me pointers on things I would be greatful
    Reply With Quote  
     

  2. #2  
    Registered Member
    Join Date
    Nov 2007
    Age
    27
    Posts
    517
    Thanks given
    1
    Thanks received
    3
    Rep Power
    73
    Great job .


    First programs are always exciting. Also, if any one replies to this with flame, just ignore it. It's been proven there's 10 year-old people on this forum who get a kick in making others miserable.

    Back on topic, my advice to you is find out what kind of learner you are. Visual, or reading. Visual you should Google some video tutorials. Reading, I wouldn't recommend the official Java tutorials for learning, when I was a beginner it made things so much harder on how they referenced to things. There are some great tutorials that make things so much simpler. The official tutorials are great if you have a general idea about Java. TO ME, I never thought they were the best for newbies.


    Another tip, if your new and you want to learn conventions (It's bad practice to learn the Mopar way first, as it becomes a habit) use:
    Code:
    ctrl + a, than ctrl + i
    This will auto conventionalize your code. Making things easier to learn to the human eye. And people will look at your code without puking.


    Code:
    class one { 
    	public static void main(String[] args) { 
    		for(int i = 0; i <= 100; i += 1); 
    			System.out.println(i);
    		}
    	}
    I added comments to show why this is incorrect practice. Here is the fix:

    Code:
    public class Practice {
    	public void main(String[] args) { 
    		for(int i = 0; i <= 100; i++) { // bracket here since for loops need an opening bracket and a closing bracket
    			System.out.println(i);
    		}
    	}
    }
    For every {, you need a }.

    Your loop was using the wrong format, use as:

    for(initiate variable here; arguement ; ++ means to increase the variable by one, so putting i++ is better practice than i += 1) {

    }

    For the statements, you need to use an opening and a closing bracket.
    Spoiler for Show GIFs:

    Reply With Quote  
     

  3. #3  
    Dev.
    Guest
    Thanks, And i think i remember you from deltascape (the real one). I have a java book in my house that i use to learn new things.
    Reply With Quote  
     

  4. #4  
    Registered Member
    Join Date
    Nov 2007
    Age
    27
    Posts
    517
    Thanks given
    1
    Thanks received
    3
    Rep Power
    73
    Quote Originally Posted by Dev. View Post
    Thanks, And i think i remember you from deltascape (the real one). I have a java book in my house that i use to learn new things.
    Yeah, you do. That's been a while though.
    Spoiler for Show GIFs:

    Reply With Quote  
     

  5. #5  
    Dev.
    Guest
    Still getting used to this eclipse stuff. I cant figure out if i can compile/run stuff with it.. time for tuts.
    Reply With Quote  
     

  6. #6  
    Registered Member
    Join Date
    Nov 2007
    Age
    27
    Posts
    517
    Thanks given
    1
    Thanks received
    3
    Rep Power
    73
    Eclipse automatically compiles when you save.
    Spoiler for Show GIFs:

    Reply With Quote  
     

  7. #7  
    Dev.
    Guest
    Ah ok thanks for that tip.

    Do you know how i can run a program through it?
    Reply With Quote  
     

  8. #8  
    ZammyPk25
    Guest
    Press F11 or
    Reply With Quote  
     

  9. #9  
    Supra
    Guest
    Where i can haz Eclipse?
    Reply With Quote  
     

  10. #10  
    Registered Member
    Join Date
    Nov 2007
    Age
    27
    Posts
    517
    Thanks given
    1
    Thanks received
    3
    Rep Power
    73
    Quote Originally Posted by THB View Post
    Where i can haz Eclipse?
    [Only registered and activated users can see links. ]
    Spoiler for Show GIFs:

    Reply With Quote  
     

Page 1 of 3 123 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

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