Java


Java is a programming language that has nothing to do with Javascript, a word related to the origin of coffee, an Indonesian island, and a kind of rhinoceros.

Programming

Java was written by Sun Microsystems in 1995. It is an industry standard language. Despite being one of the older programming languages in use, it remains popular due to being easy to learn, good for writing large and complex software solutions, having a ton of libraries, and having a strong community with plenty of resources.

Java is object oriented, strictly typed, compiled, and has memory management.

(DEV276x)

Java is a single rooted hierarchy object-oriented programming language in which all classes inherited directly or indirectly from this single root: Object. All classes have Object as superclass.

It offers the Standard Java Library, which is documented using the Javadoc tool.

(IT.1.1x)

List

  • Java SE, Java Standard Edition
  • Java EE, Java Enterprise Edition - Built on SE to deal with large-scale applications
  • Java ME, Java Micro Edition - Subset of SE suited for small and embedded devices

Topics

  • Assignment Statement
  • BigDecimal
  • Cast
  • ceil
  • Character
  • Class
  • Class Constant
  • Class Variable
  • Clone
  • Comment
  • Console
  • Control Flow
  • Data Structure
  • Data Type
  • Equals
  • If Statement
  • List: LinkedList vs. ArrayList
  • Literal
  • Local Variable
  • Logic Control Structure
  • Main Method
  • Memory Allocation: Statically allocated memory vs. dynamically allocated memory
  • Method
  • Modulus
  • Out
  • Primitive Data Type
  • Print
  • Println
  • Private
  • Procedural Composition
  • Programming
  • Public
  • Relational Operator, Relational Operation
  • Scanner
  • Scope
  • Statement
  • Static
  • String
  • System
  • toString()
  • Variable

Basics

Every application begins with a class name, and that class must match the filename.

Write a .java file. To run it in Mint, you have to compile it first. Use "javac MyClass.java," and it will make a MyClass.class file for you. To run, use "java MyClass."

Generally, there are three different pieces of a Java program: class, method, and statement.

(DEV276x)

Math Shortcuts

  • Operator - example - equivalent
  • ++ - x++; - x = x + 1;
  • -- - x--; - x = x - 1;
  • += - x += y; - x = x + y
  • %= - x %= y; - x = x % y;

(DEV276x)

Naming Conventions

  • HelloWorld, not Hello World, Hello_World, helloWorld
  • Start class name with capital letter
  • No spaces allowed in class name
  • Java file must share name with class name.
  • Code is contained within curly braces.
  • Indentations mark each level of curly brace.
  • Lines end with either a curly brace or a semicolon.

(DEV276x)

IDE

  • Eclipse - makes enterprise code
  • IntelliJ IDEA