Learn JAVA in 30 minutes

Posted by MrCool on Wed, 31 Jul 2019 04:14:30 +0200

In this Java programming tutorial, I'll teach you all the core knowledge you need to write Java code in 30 minutes.

I specifically cover the following topics: raw data types, annotations, classes, imports, Scanner, final, string, static, private, protected, public, constructor, mathematics, hasNextLine, nextLine, getters, setter, method overloading, Random, cast, toString, from strings to primitives, from primitives Convert to a string, if, else, else if else, print, println, printf, logical operators, comparison operator, trinary operator, switch, for, while, break, continue, do while, polymorphism, array, each, multidimensional array, etc.

Video download (see https://via-dean.com)

Memorandum sheet (excerpts):

// A Single line comment

/* A 
 * Multiple line
 * comment
 */

// You can import libraries with helpful methods using import

import java.util.Scanner;
import java.util.*;

// A class defines the attributes (fields) and capabilities (methods) of a real world object

public class Animal {
	
	// static means this number is shared by all objects of type Animal
	// final means that this value can't be changed
	public static final double FAVNUMBER = 1.6180;
	
	// Variables (Fields) start with a letter, underscore or $
	// Private fields can only be accessed by other methods in the class
	
	// Strings are objects that hold a series of characters
	private String name;
	
	// An integer can hold values from -2 ^ 31 to (2 ^ 31) -1
	private int weight;
	
	// Booleans have a value of true or false
	private boolean hasOwner = false;
	
	// Bytes can hold the values between -128 to 127
	private byte age;
	
	// Longs can hold the values between -2 ^ 63 to (2 ^ 63) - 1
	private long uniqueID;
	
	// Chars are unsigned ints that represent UTF-16 codes from 0 to 65,535
	private char favoriteChar;
	
	// Doubles are 64 bit IEEE 754 floating points with decimal values
	private double speed;
	
	// Floats are 32 bit IEEE 754 floating points with decimal values
	private float height;
	
	// Static variables have the same value for every object 
	// Any variable or function that doesn't make sense for an object to have should be made static
	// protected means that this value can only be accessed by other code in the same package
	// or by subclasses in other packages
	
	protected static int numberOfAnimals = 0;
	
	// A Scanner object allows you to except user input from the keyboard
	static Scanner userInput = new Scanner(System.in);
	
	// Any time an Animal object is created this function called the constructor is called
	// to initialize the object
	public Animal(){
		
		// Shorthand for numberOfAnimals = numberOfAnimals + 1;
		numberOfAnimals++;
		
		int sumOfNumbers = 5 + 1;
		System.out.println("5 + 1 = " + sumOfNumbers);
		

Topics: Java Programming