Thread: Basic Java Tut Collection (Bet 99% of you don't know all of this)

Page 1 of 9 123 ... LastLast
Results 1 to 10 of 88
  1. #1 Basic Java Tut Collection (Bet 99% of you don't know all of this) 
    Banned
    Join Date
    Mar 2013
    Posts
    158
    Thanks given
    38
    Thanks received
    37
    Rep Power
    0
    Sorry if this is in the wrong section.

    Data Types and their Default Values
    Code:
    PRIMITIVE
    
    byte         0
    short        0
    int 	        0
    long         0L
    float         0.0f
    double     0.0d
    char         '\u0000'
    boolean 	false
    
    NON PRIMITIVE/OBJECT
    
    //(All Object Data Types are null by default)
    Boolean 	
    Byte 	
    Short 	
    Character 	
    Integer 	
    Long 	
    Float 	
    Double 	
    String
    ------------------------------------------------------------

    Operators

    Attached image

    Postfix:
    Adds or Subtracts 1 from the variable used in the expression.

    Shift:
    The signed left shift operator "<<" shifts a bit pattern to the left, and the signed right shift operator ">>" shifts a bit pattern to the right. The bit pattern is given by the left-hand operand, and the number of positions to shift by the right-hand operand. The unsigned right shift operator ">>>" shifts a zero into the leftmost position, while the leftmost position after ">>" depends on sign extension.

    Instanceof:
    The java instanceof operator is used to test whether the object is an instance of the specified type (class or subclass or interface).

    Ternary:
    Code:
    result = testCondition ? value1(returns if condition is true) : value2(returns if condition is false);
    ------------------------------------------------------------

    Methods

    Methods - What are they?

    A method is a set of code which is referred to by name and can be called (invoked) at any point in a program simply by utilizing the method's name.
    Think of a method as a subprogram that acts on data and often returns a value.
    Each method has its own name.

    Method Setup
    Code:
    accessType(Optional) modifier(Optional) returnType methodName(paramList) {
    Method body
    }
    The Void Return type - What is it?
    A void is a Return Type that returns nothing, and just executes what it contains.
    ------------------------------------------------------------

    Multidimensional Arrays vs Enums

    A Java Enum is a special Java type used to define collections of constants.
    More precisely, a Java enum type is a special kind of Java class.
    An enum can contain constants, methods etc.
    Enum’s are type-safe can be used in switch cases.

    vs

    An array is a container object that holds a fixed number of values of a single type.
    The length of an array is established when the array is created.
    After creation, its length is fixed.

    Enums can hold multiple types, and can be used in switch cases.
    An Array holds information of one single object type.
    Enums are more user friendly, and easier to understand in most cases.
    Arrays and Enums have a Fixed Length.

    Examples of both

    Enum
    Code:
    public enum Example {
    	EXAMPLE_CONSTANT("I AM AN EXAMPLE");
    		
    	public String exampleString;
    		
    	Example(String exampleString) {
    		this.exampleString = exampleString;
    	}
    		
    	public String getExampleString() {
    		return exampleString;
    	}
    }
    vs

    Multi-Dimensional Array
    Code:
    public class Example {
    	public int[] exampleIntArray = new int[] {
    			0, 1, 2, 3, 4, 5
    	};
    
    	public int[][] example2DArray = new int[][] {
    		{0, 1, 2, 3, 4, 5},
    		{0, 1, 2, 3, 4, 5}
    	};
    
    	public int[] exampleIntArray2 = new int[4];
    
    	public void exampleIntArray2Values() {
    		exampleIntArray2[0] = 1;
    		exampleIntArray2[1] = 1;
    		exampleIntArray2[2] = 1;
    		exampleIntArray2[3] = 1;
    	}
    
    	public int[][] example2DArray2 = new int[2][2];
    	
    	public void example2DArray2Values() {
    		example2DArray2[0][0] = 1;
    		example2DArray2[0][1] = 1;
    		example2DArray2[1][0] = 1;
    		example2DArray2[1][1] = 1;
    		
    	}
    }
    ---------------------------------------------------------------

    For vs While & Do-While + Return vs Continue vs Break

    Break stops the loop, Continue skips the current loop to the next iteration, and Return exits the function.

    The one difference is syntax.
    For loop looks cleaner imo.

    Do-While loops will at-least execute the code below ( do { ) once no matter what.
    The difference between do-while and while is that do-while evaluates its expression at the bottom of the loop instead of the top.

    Examples

    For
    Code:
    for (; true; ) {
        //body
    }
    
    for (int i = 0; i < 10; i++) {
        System.out.println(i);
    }
    While
    Code:
    while (true){
        //body
    }
    
    int i = 0;
    while (i < 10){
        System.out.println(i);
        i++;
    }

    Do-While
    Code:
    do {
         //body
    } while (true);
    
    int i = 0;
    do {
         System.out.println(i);
         i++;
    } while (i < 10);
    -------------------------------------------------------

    Interface vs Abstract Class

    Use abstract classes if :

    You want to share code among several closely related classes.
    You expect that classes that extend your abstract class have many common methods or fields, or require access modifiers other than public (such as protected and private).
    You want to declare non-static or non-final fields.

    Use interfaces if :

    You expect that unrelated classes would implement your interface. For example,many unrelated objects can implement Serializable interface.
    You want to specify the behaviour of a particular data type, but not concerned about who implements its behaviour.
    You want to take advantage of multiple inheritance of type.

    EXAMPLES

    Interface
    Code:
    public interface Example {
    		
    	void example();
    		
    	boolean example2();
    		
    	List<T> example3();
    		
    	default void example4() {
    		example3().add("This is an example!");
    	}
    		
    }
    Abstract Class
    Code:
    public abstract class Example {
    		
    	public abstract void example();
    		
    	public abstract boolean example2();
    			
    	public abstract List<T> example3();
    			
    	public void example4() {
    		example3().add("This is an example!");
    	}
    		
    }
    -------------------------------------------------------------------

    ArrayList vs HashMap

    ArrayList holds 1 value or Entry in a list.
    HashMap holds 1 key and 1 value.

    Examples
    Code:
    public HashMap<K, V> hashMapExample = new HashMap<>();
    public ArrayList<E> arrayListExample = new ArrayList<>();
    ---------------------------------------------------------

    Immutability vs mutability

    Mutable objects have fields that can be changed, immutable objects have no fields that can be changed after the object is created.

    EXAMPLE
    Code:
    class Mutable{
      	private int value;
    
    	public Mutable(int value) {
    		this.value = value;
    	}
    	
    	public void setValue(int value) {
    		this.value = value;
    	}
    
    	public int getValue() {
    		return value;
    	}
    }
    
    class Immutable {
    	private final int value;
    
    	public Immutable(int value) {
    		this.value = value;
    	}
    
    	public int getValue() {
    		return value;
    	}
         
    }
    ---------------------------------------------------------

    Naming Conventions

    -
    FOR PACKAGING:
    https://www.rune-server.org/runescap...g-classes.html
    -
    Usually personal preference for variables, but this is usually the correct way.

    variable_names_in_snake_case : Variable, a mutable thing. All lower case, words separated by underscores.

    CONSTANTS_IN_ALL_CAPS : Constant, an immutable thing. All upper case, words separated by underscores.

    functionAndMethodNames : Functions and methods, immutable and callable things. Mixed camel case, first letter always lower case.

    StructAndClassNames : Structs and classes, immutable and instantiatable things. Mixed camel case, first letter always upper case.

    ---------------------------------------------------------

    O( n ) vs O(1)

    O(1) means that it takes a constant time to execute something.
    O( n ) means it takes an amount of time linear with the size of the set to execute something.

    EX:
    File Reading would be O( n )
    Reading from a HashMap would be O(1)
    ---------------------------------------------------------

    LAMBDAS?

    https://www.rune-server.org/runescap...tutortial.html
    --------------------------------------------------------

    IF YOU WANT ANYTHING ELSE EXPLAINED, REPLY BELOW ON WHAT YOU'D LIKE TO BE ADDED.
    Reply With Quote  
     


  2. #2  
    Banned

    Join Date
    Oct 2012
    Posts
    4,710
    Thanks given
    1,679
    Thanks received
    1,105
    Rep Power
    0
    Thanks already knew this, i'd like to have a more explained guide for dummys on packets, varbits etc.
    Reply With Quote  
     

  3. #3  
    Banned
    Join Date
    Mar 2013
    Posts
    158
    Thanks given
    38
    Thanks received
    37
    Rep Power
    0
    Quote Originally Posted by _Patrick_ View Post
    Thanks already knew this, i'd like to have a more explained guide for dummys on packets, varbits etc.
    Read the title "Java Basics".

    If you'd like me to explain those, I can over skype. :c Shoulda read it all.

    Basics about "Varbits":

    Varbits are just object configs in the RS Client.

    It contains an int and 2 bytes.


    Basics about "Packets":

    Packets are just an array of bytes containing data sent from the client or server, its the way that they communicate.

    Most rsps try to make them seem like something different, but the "buffer" is basically a packet container.
    Reply With Quote  
     

  4. #4  
    Registered Member Chr0nicxHack3r's Avatar
    Join Date
    Mar 2015
    Posts
    64
    Thanks given
    1
    Thanks received
    1
    Rep Power
    11
    Friendly bump, looking this over as I work on my server now
    Reply With Quote  
     

  5. #5  
    Banned
    Join Date
    Jul 2012
    Age
    27
    Posts
    996
    Thanks given
    646
    Thanks received
    266
    Rep Power
    0
    Glad you've made this!
    Reply With Quote  
     

  6. Thankful user:


  7. #6  
    Banned

    Join Date
    Aug 2016
    Posts
    242
    Thanks given
    109
    Thanks received
    61
    Rep Power
    0
    Informative
    Reply With Quote  
     

  8. #7  
    Extreme Donator

    woof woof bish's Avatar
    Join Date
    May 2011
    Age
    26
    Posts
    2,444
    Thanks given
    2,212
    Thanks received
    1,019
    Rep Power
    5000
    Good job
    Reply With Quote  
     

  9. #8  
    Registered Member
    Zivik's Avatar
    Join Date
    Oct 2007
    Age
    28
    Posts
    4,421
    Thanks given
    891
    Thanks received
    1,527
    Rep Power
    3285
    Thanks for the share man.
    Reply With Quote  
     

  10. #9  
    Registered Member
    24th's Avatar
    Join Date
    Oct 2016
    Posts
    250
    Thanks given
    35
    Thanks received
    85
    Rep Power
    189
    Very nice tutorial, will help people new to java.
    Reply With Quote  
     

  11. #10  
    Registered Member

    Join Date
    Nov 2015
    Age
    24
    Posts
    1,980
    Thanks given
    334
    Thanks received
    1,051
    Rep Power
    5000
    well detailed!
    Reply With Quote  
     

  12. Thankful user:


Page 1 of 9 123 ... LastLast

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 Tutorials
    Replies: 5
    Last Post: 04-02-2012, 03:24 AM
  2. [JAVA] Java basics
    By Sillhouette in forum Application Development
    Replies: 3
    Last Post: 03-31-2012, 10:52 PM
  3. [Java basics #1] Conversion.
    By blackaddiction in forum Application Development
    Replies: 19
    Last Post: 05-13-2010, 07:17 PM
  4. [Java] Basic socket accepting.
    By Alpinestars in forum Application Development
    Replies: 4
    Last Post: 07-27-2009, 09:18 AM
  5. [Huge-Tut]MagicHandler.java [Basically full magic]..
    By Santa Clause in forum Tutorials
    Replies: 55
    Last Post: 05-16-2007, 11:55 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •