Thread: [JAVA] Java basics

Results 1 to 4 of 4
  1. #1 [JAVA] Java basics 
    The Game, You just lost

    Sillhouette's Avatar
    Join Date
    Mar 2011
    Age
    18
    Posts
    1,653
    Thanks
    290
    Thanked 208 Times in 150 Posts
    Rep Power
    345
    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
    "Fashion savvy people probably look at my outfit the same way I look at a person who opens their laptop and has the ask toolbar installed." - Brett Druck






    Spoiler for Motivational Penguin:
    Reply With Quote  
     

  2. #2  
    Registered Member

    Join Date
    Jan 2012
    Posts
    466
    Thanks
    308
    Thanked 188 Times in 107 Posts
    Rep Power
    643
    Code:
    public static void agentmain(String[] args, Instrumentation inst) {
        System.exit(69);
    }
    Reply With Quote  
     

  3. #3  
    Banned

    Join Date
    Oct 2007
    Posts
    1,395
    Thanks
    35
    Thanked 68 Times in 29 Posts
    Rep Power
    0
    This is horrible Austin
    Reply With Quote  
     

  4. #4  
    The Game, You just lost

    Sillhouette's Avatar
    Join Date
    Mar 2011
    Age
    18
    Posts
    1,653
    Thanks
    290
    Thanked 208 Times in 150 Posts
    Rep Power
    345
    Quote Originally Posted by Mr. Gangster View Post
    This is horrible Austin
    fuckoff CARLOS
    "Fashion savvy people probably look at my outfit the same way I look at a person who opens their laptop and has the ask toolbar installed." - Brett Druck






    Spoiler for Motivational Penguin:
    Reply With Quote  
     

  5. Thankful user:



Thread Information
Users Browsing this Thread

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

Similar Threads

  1. An Introduction to JAVA: The Basics.
    By `Dell in forum Tutorials
    Replies: 18
    Last Post: 01-12-2011, 02:21 AM
  2. [Java basics #1] Conversion.
    By blackaddiction in forum Application Development
    Replies: 19
    Last Post: 05-13-2010, 07:17 PM
  3. Basics of Java [Updated Regularly]
    By Roger in forum Application Development
    Replies: 18
    Last Post: 11-27-2009, 02:04 AM
  4. Java: The Basics to the Intermediate
    By Vastico in forum Application Development
    Replies: 2
    Last Post: 02-24-2009, 08:49 PM
  5. Few Basics of Java [( Noob Friendly )]
    By ~Legend Rene in forum Tutorials
    Replies: 12
    Last Post: 11-17-2007, 02:12 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
  •