User Tools

Site Tools


user:afassett:start:bilingual:java

Java

Template

  class //fileName// {
    public static void main(String[] args) {
       //Code//
    }
  }

Examples

  class HelloWorldApp {
    public static void main(String[] args) {
        System.out.println("Hello World!"); // Display the string.
    }
  }
Jwindow

Tutorials

Java main
invoking a method or calling a method is followed by a period. Than argument(s). Assignment operator is an instruction to set the value of the variable on the left-hand side of the equal sign. Java program into a language called byte-code. Byte-code is the machine language for a fictitious computer called the Java virtual machine. Name of a variable is called an identifier. Java identifier must not start with digit and all the characters must be letters, digits or underscore symbol. “$” is allowed but is reserved for special purposes. Java is case sensitive.. When one or more variables are declared on the same line they are separated by a comma.
Primitive types
|Type Name|Kind of Value| Memory Used | Size Range|
| Boolean |true or false| 1 byte | not applicable |
| char | single character | 2 byte | all Unicode chars |
| byte | integer | 1 byte | -128 to 127 |
| short | integer | 2 byte | 237868 to 32767 |
| int | integer | 4 bytes | -2147483648 to 2147483647 |
| long | integer | 8 bytes | - 9223372036854775808 to 9223372036854775808 |
| float | floating-point # | 4 bytes | +/-3.40282347×10^38 to +/-1.40239846×10^45 |
| double | floating-point # | 8 bytes | ? |


A variable that has been declared but that has not yet been given a value by some means, such as an assignment statement is said to be uninitialized. Rule of thumb not to store a value of one type into an variable of another type. Some special cases where it is permitted (int to double).
generally you can assign a value of any type in the following list to a variable of any type that appears further down in the list.

              byte->short->int->long->float->double\\

As you move father down the list the range gets large. A int can be a long, float, and double but not a short or byte. char to a in or any of the numeric type that follow int can cast.
*pages22-23.

References

docs
Absolute Java

user/afassett/start/bilingual/java.txt · Last modified: 2011/09/12 02:21 by afassett