The Java(tm) FAQ -- Java Language

Copyright        Table of Contents        Chapters:   1   2   3   4   5   6   7   8   9   10   11

Outline


Constants and Expressions


Q2.1
What is the difference between Integer and int in Java -- why do I get the following error: Can't convert java.lang.Integer to int?

See also: Q2.11


Q2.2
How do I treat all 8 bits of a byte as an unsigned quantity?

UnsignedByteExample.html

See also: Q2.1, JLS pp. 61–75


Q2.3
How do I work around Java's lack of true enums?

See also: Q2.1


Q2.4
Why is goto a reserved keyword in Java -- shouldn't it be outlawed?

KeywordExample.html

See also: JLS p. 18, JLS pp. 283--286


Q2.5
What are some guidelines for using uppercase and lowercase letters in my identifiers?

See also: JLS pp. 106–111


Q2.6
Is there any limit to the length of an identifier?

See also: JVMS p. 100


Q2.7
Why doesn't Java have user-defined operator overloading?

See also: Q11.1


Q2.8
Why do I have to put an f after a floating point constant?

See also: Q2.9


Q2.9
How and when can I cast from one class to another?

See also: Q1.10, Q1.26, Q2.8, Q2.11, Q2.15


Q2.10
Can I use C-like data structures in Java?

See also: Q1.1, Q1.2, Q1.3


Variables and Methods


Q2.11
Are Java objects pointers?

See also: Q1.1, Q1.2, Q1.10, Q2.1, Q2.12, Q2.13


Q2.12
In a method invocation, does Java pass arguments by reference or by value?

See also: Q1.10, Q2.1, Q2.11, Q11.1


Q2.13
If the Java language lacks pointers, how do I implement classic pointer structures like linked lists?

LinkedListExample.html

See also: Q1.10, Q2.11, Q2.12


Q2.14
What does the following error message mean: Can't make a static reference to nonstatic variable?

See also: Q1.5, Q1.6


Q2.15
In a class method, how can I get the name of the class, or create a new instance of the class?

ClassClassExample.html

See also: Q1.30, Q2.16, Q3.7


Q2.16
Can I write a method that delivers dynamically (at run time) all public methods of an object?

GetMethod11Example.html

See also: Q2.17, Q2.18


Q2.17
Can I invoke methods dynamically, from names (String instances) that are determined at run time?

InvokeMethodDynamically11Example.html

See also: Q2.1, Q2.16, Q2.22, Q2.23


Q2.18
How can I accomplish the equivalent of function pointers in Java, for instance, for use in an array?

MethodTable11Example.html

See also: Q7.2


Arrays


Q2.19
Can I allocate an array dynamically?

See also: Q2.20, JLS p. 193


Q2.20
How do I initialize an array of objects?

InitializeObjectArrayExample.html

See also: Q2.11


Q2.21
If arrays are objects, why can't I use a length method to determine an array's size?

Exceptions


Q2.22
What is an exception?

ExceptionExample.html

See also: Q2.23


Q2.23
Why does the compiler complain about InterruptedException when I try to use Thread's sleep method?

See also: Q2.22, Q2.24


Q2.24
Why do methods have to declare the exceptions they can throw?

See also: Q2.22, Q2.23, Q2.25


Q2.25
What's the difference between a runtime exception and a plain exception -- why don't runtime exceptions have to be declared?

See also: Q2.24, Q2.25