Thread: [JAVA] Java basics

Results 1 to 6 of 6
  1. #1 [JAVA] Java basics 
    I'm Baack...


    Join Date
    Mar 2011
    Posts
    1,663
    Thanks given
    281
    Thanks received
    202
    Rep Power
    324
    I'm starting to teach a friend about the basics of java and I wrote up this example class to demonstrate them. I figured someone on here can use it to learn so I'm going to post it here for you to do whatever with it. Maybe some leechers can learn something for once eh?

    Here it is:

    Code:
    /*
     * Classname = Tester
     * 
     * Version information = null
     *
     * Date = 3/30/12
     * 
     * Copyright notice = null
     */
    
    /**
     * This is a small tutorial to explain java basics
     * Written by Austin Melchior AKA Sillhouette for Joey
     * Released to the public
     * Resources used: Java conventions defined by Oracle
     * http://www.oracle.com/technetwork/java/codeconv-138413.html
    */
    
    /**
     * We will start off by looking at the placement of code
    */
    
    /*Package statement goes here*/
    ///No package currently
    
    /*Imports go here*/
    import java.util.*; //This imports the java.util package
    					//the "*" refers to all files in that directory
    					
    /*
     * Now you declare your class
     * @public, public is the scope of the class
     * 			that will be talked with in further depth later
    */
    public class JavaTutorial {
    	/**
    	 * Comments on what the class is for go here
    	 * This class is merley to test different basic concepts
    	*/
    	
    	/*Next we add the variables of the class
    	 * The order of these is as follows:
    	 * First the public static class variables, then the protected static,
    	 * then package static level (no access modifier), and then the private static
    	 * then the public  class variables, then the protected,
    	 * then package level (no access modifier), and then the private.
    	*/
    	
    	///Static Variables
    	public static int statInt = 7; //Integer between roughly -2.147b and 2.147b
    	protected static double protStatDbl = -54.5; //Double is a number that has a decimal point
    	static boolean pkgStatBoolean = false; // Booleans have only two values, True and False 
    	private static String prvtStatString = ""; // A string is a decleration of a string of characters, like a word
    	
    	///Non-Static Variables
    	public double pubDbl = -5735.68; // Declaring a variable and assigning a value can be done in the same line, assigning a value is called instantion.
    	protected boolean protBoolean; //You can declare variables without assigning a value, this is called decleration.
    	char pkgChar = 'c'; // A char is a single character, can be anything from "~" to letters or even numbers
    	private long prvtLong= 6857 * 5683; //You can declare numbers by suing arithmatic equations as well, A long is a number bigger the 2.147b,
    	
    	/*
    	 * Now we have the constructors, Both default and non-default
    	 * You can have as many constructors as you want as long as they have different parameters
    	 * Constructors are always defined by the class name, a few examples are given
    	*/
    	
    	///Default Constructor
    	public void Tester(){
    		protStatDbl = pubDbl * statInt;
    	}
    	
    	///Non-Default Constructors
    	public void Tester(int input1, String input2, boolean input3){
    		input3 = protBoolean;
    		input2 = prvtStatString;
    		input1 = statInt;
    	}
    	
    	/*
    	 * Now we have the methods
    	 * Rather then being grouped by scope, methods are grouped by functionality and readability
    	 * Methods are defined with a return type eg: int, String, or void(returns nothing)
    	 * A few examples are given below.
    	*/
    	public static void main(String args[]){
    		//This is the main method used to run a java applet or application
    	}
    	
    	//returns an int
    	public int intMethod(){
    		int temp = 2 * statInt;
    		return temp;
    	}
    	
    	//returns nothing
    	public void voidExample(){
    		for(int i = 0; i < 2; i++){
    			i = i + 2;
    		}
    	}
    }
    And here it is as a notepad file:

    http://up.ht/HaMO2J

    I'm open to any and all suggestions or criticisms rate/hate

    Thanks all
    I'm back
    Reply With Quote  
     

  2. #2  
    Registered Member Treq's Avatar
    Join Date
    Aug 2010
    Posts
    463
    Thanks given
    71
    Thanks received
    65
    Rep Power
    22
    Looks pretty good, I don't think this is the best way to learn java though. (Unless your talking him through it)
    ~Treq~ (Previously Spetsnaz)
    Reply With Quote  
     

  3. #3  
    I'm Baack...


    Join Date
    Mar 2011
    Posts
    1,663
    Thanks given
    281
    Thanks received
    202
    Rep Power
    324
    Quote Originally Posted by Spetsnaz View Post
    Looks pretty good, I don't think this is the best way to learn java though. (Unless your talking him through it)
    With him I'm going to be talking him through it. I just released the resource I'm going to be using.
    I'm back
    Reply With Quote  
     

  4. #4  
    Banned

    Join Date
    Feb 2012
    Age
    27
    Posts
    474
    Thanks given
    20
    Thanks received
    65
    Rep Power
    0
    another one of these?

    TheNewBoston is all you need. Not unneeded threads.
    Reply With Quote  
     

  5. #5  
    Registered Member Mayday Parade's Avatar
    Join Date
    Apr 2009
    Age
    27
    Posts
    495
    Thanks given
    20
    Thanks received
    17
    Rep Power
    8
    I hope your friend learns haha. But I don't think this belongs in the RS Client board, more of just the programming board

    Spoiler for LoL:
    Quote Originally Posted by Imbued View Post
    Quote Originally Posted by pasta186 View Post
    That tutorial doesnt walk.
    That's because it got no legs..
    Best report I've sent? "Mass spam? Also in wrong sexual"
    LOL
    Reply With Quote  
     

  6. #6  
    I'm Baack...


    Join Date
    Mar 2011
    Posts
    1,663
    Thanks given
    281
    Thanks received
    202
    Rep Power
    324
    Quote Originally Posted by Mayday Parade View Post
    I hope your friend learns haha. But I don't think this belongs in the RS Client board, more of just the programming board
    its here because i see in the help sections how so many people don't know anything about java and attempt to code rsps, my goal was to teach them something.
    I'm back
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

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


User Tag List

Similar Threads

  1. [JAVA] Java basics
    By Sillhouette in forum Application Development
    Replies: 3
    Last Post: 03-31-2012, 10:52 PM
  2. An Introduction to JAVA: The Basics.
    By `Dell in forum Application Development
    Replies: 18
    Last Post: 01-12-2011, 03:21 AM
  3. [Java basics #1] Conversion.
    By blackaddiction in forum Application Development
    Replies: 19
    Last Post: 05-13-2010, 07:17 PM
  4. Basics of Java [Updated Regularly]
    By Roger in forum Application Development
    Replies: 18
    Last Post: 11-27-2009, 03:04 AM
  5. Java: The Basics to the Intermediate
    By Vastiko in forum Application Development
    Replies: 2
    Last Post: 02-24-2009, 09:49 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •