0% found this document useful (0 votes)
3 views18 pages

Java Book

The document provides a comprehensive overview of Java data types, object equality, and collection frameworks such as HashMap and ArrayList. It discusses concepts like memory management, exception handling, and synchronization in concurrent programming. Additionally, it highlights the differences between primitive types and their wrapper classes, as well as the behavior of strings and their manipulation.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views18 pages

Java Book

The document provides a comprehensive overview of Java data types, object equality, and collection frameworks such as HashMap and ArrayList. It discusses concepts like memory management, exception handling, and synchronization in concurrent programming. Additionally, it highlights the differences between primitive types and their wrapper classes, as well as the behavior of strings and their manipulation.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

HashMap

HashMap
byte

short

int

long

float

double

char

boolean

float double
1/3
double float
BigDecimal

Integer
==

== .equals()

130 byte
130 10000010
1 -126

130 - 256 = -126

-126
[Link](7 % -3);

[Link](127) == [Link](127) true new


Integer(127) == new Integer(127) false new Integer()

long int

double

-1 %

valueOf
== true new Integer()
== false
==
long max = Long.MAX_VALUE; [Link](max + 1);
Long.MIN_VALUE
[Link](a - b) < 1e-9 BigDecimal

String
concat replace substring String

"abc"
"abc"
== true

String s = new String("abc")


==
== String
.equals()

result += x
String
StringBuilder

true false
new String("java")
.intern()
"java" a .intern() a

true

String
HashMap
[Link]("5" + 3 + 2); [Link](5 + 3 + "2");

+=
StringBuilder

String

HashMap

"5" + 3 + 2 "5"+3 "53" "53"+2 "532" 5 + 3 +


"2" 5+3 8 8+"2" "82"

StringBuilder sb = new StringBuilder(); for (String s : items) {


[Link](s).append(","); } String result = [Link]();

param = new Thing()

[Link](5)
NullPointerException

.equals()
hashCode() HashSet HashMap
Base init() [Link]()
Derived name null

null
A obj.x A 10
getX() B
[Link]() B x 20

10 20

Point x y equals()
hashCode() HashSet
Point(1,2) .equals() hashCode()
hashCode() HashSet
hashCode() equals()

hashCode() equals() [Link](x, y)

null
0

Throwable Error
OutOfMemoryError Exception Exception
IOException
RuntimeException NullPointerException

NullPointerException IndexOutOfBoundsException

try-with-resources AutoCloseable
finally
return finally
return finally

finally return [Link]()


[Link]()
catch finally StringBuilder
toString() String
finally sb

"try-catch-" finally- sb
try/finally finally

finally
try

try (FileReader fr = new FileReader("[Link]")) { ... } close()


finally close()

NullPointerException
try { throw new RuntimeException("original"); } finally { throw new
RuntimeException("replacement"); }
finally

ArrayList
LinkedList

HashSet
hashCode equals LinkedHashSet TreeSet
Comparable Comparator

HashMap LinkedHashMap TreeMap

Object
new T[] instanceof List<String> T
String
? extends T
? super T

Iterator
[Link]() [Link](i -> i == 2)

new T[]

Object[] Class<T>
copy(List<? extends T> src, List<? super T> dest)

ConcurrentModificationException
TreeMap Comparable Comparator
HashMap

src ? extends T dest


? super T
List<Integer> List<Number> List<T>

Iterator<Integer> it = [Link]();
while([Link]()){ if([Link]()==2) [Link](); } [Link](i -> i ==
2);
TreeMap
Comparable Comparator HashMap
hashCode() equals()

synchronized
volatile

count++

synchronized volatile

AtomicInteger [Link]() synchronized

HashMap

ConcurrentHashMap
volatile get()
increment() count = count + 1

volatile

AtomicInteger synchronized void increment()

Counter AtomicInteger
synchronized
volatile

private final AtomicInteger count = new AtomicInteger(0); public void


increment(){ [Link](); } public int get(){ return [Link](); }
synchronized
volatile
Integer a=127,b=127; a==b? true

Integer a=200,b=200; a==b? false

5/2 2

0.1+0.2==0.3 false

"a"+"b"=="ab" true

new String("a")=="a" false

null String Object String

finally return try catch

List ConcurrentModificationException

equals() hashCode() HashSet HashMap

volatile int count++

new T[]

List<String>.getClass()==List<Integer>.getClass() true

byte b=(byte)130; -126

Integer.MAX_VALUE+1 Integer.MIN_VALUE

char c='a'; c+1 98 'b'


ArrayList HashMap String

You might also like