User Tools

Site Tools


quickref:java

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

quickref:java [2013/04/15 11:57]
andy created
quickref:java [2013/04/15 17:07]
andy
Line 2: Line 2:
  
 This page holds notes that I've made whilst brushing up on my Java. It may be useful to anybody else who's coming from a C++ background, but it's unlikely to be of interest to anybody who's already familiar with Java basics, or whose learning it as a first language. This page holds notes that I've made whilst brushing up on my Java. It may be useful to anybody else who's coming from a C++ background, but it's unlikely to be of interest to anybody who's already familiar with Java basics, or whose learning it as a first language.
 +
 +===== Data Types =====
 +
 +Java has similar basic types to C/C++ but whose definition is more rigorously defined. All integer types are signed, Java has no unsigned types.
 +
 +^ ''​byte''​ | 8-bit signed integer |
 +^ ''​short''​ | 16-bit signed integer |
 +^ ''​int''​ | 32-bit signed integer |
 +^ ''​long''​ | 64-bit signed integer |
 +^ ''​float''​ | 32-bit IEEE-754 floating point value |
 +^ ''​double''​ | 64-bit IEEE-754 floating point value |
 +^ ''​boolean''​ | Either ''​true''​ or ''​false''​ |
 +^ ''​char''​ | 16-bit Unicode character value (strings are UTF-16) |
 +
 +Java also has fixed-size arrays which are declared using C-style empty square brackets syntax and allocated with ''​new''​ just like classes:
 +
 +<code java>
 +int[] arrayType;
 +arrayType = new int[16];
 +</​code>​
 +
 +Once created the array size is fixed, although array variables can be assigned to a different array. C-like shorthand notation for an array literal can also be used:
 +
 +<code java>
 +int[] arrayType = {1, 2, 3, 4};
 +</​code>​
 +
 +All other objects in Java are reference types, similar to Python. The equivalent to Python ''​None''​ is ''​null'',​ similar to C/C++.
 +
  
 ===== Classes and Scopes ===== ===== Classes and Scopes =====
quickref/java.txt ยท Last modified: 2013/04/15 17:07 by andy