|
byte / short / int / long
|
-123, 10
|
|
float / double
|
235.13
|
|
char
|
'U'
|
|
boolean
|
true, false
|
|
String
|
"Greetings from earth"
|
|
s.length()
|
length of s
|
|
s.charAt(i)
|
extract ith character
|
|
s.substring(start, end)
|
substring from start to end-1
|
|
s.toUpperCase()
|
returns copy of s in ALL CAPS
|
|
s.toLowerCase()
|
returns copy of s in lowercase
|
|
s.indexOf(x)
|
index of first occurence of x
|
|
s.replace(old, new)
|
search and replace
|
|
s.split(regex)
|
splits string into tokens
|
|
s.trim()
|
trims surrounding whitespace
|
|
s.equals(s2)
|
true if s equals s2
|
|
s.compareTo(s2)
|
0 if equal/+ if s > s2/- if s < s2
|
|
l.add(itm)
|
Add itm to list
|
|
l.get(i)
|
Return ith item
|
|
l.size()
|
Return number of items
|
|
l.remove(i)
|
Remove ith item
|
|
l.set(i, val)
|
Put val at position i
|
|
m.put(key,value)
|
Inserts value with key
|
|
m.get(key)
|
Retrieves value with key
|
|
m.containsKey(key)
|
true if contains key
|
|
x + y
|
add
|
x - y
|
subtract
|
|
x * y
|
multiply
|
x / y
|
divide
|
|
x % y
|
modulus
|
++x / x++
|
increment
|
|
--x / x--
|
decrement
|
|
x < y
|
Less
|
x <= y
|
Less or eq
|
|
x > y
|
Greater
|
x >= y
|
Greater or eq
|
|
x == y
|
Equal
|
x != y
|
Not equal
|
|
! x (not)
|
x && y (and)
|
x || y (or)
|
try { staÂtemÂents; } catch (ExceÂptiÂonType e1) { staÂtemÂents; } catch (Exception e2) { catÂch-all statemÂents; } finally { staÂtemÂents; } We can write the above code like this also try { staÂtemÂents; } catch (ExceÂptiÂonType | Exception e1) { staÂtemÂents; } finally { staÂtemÂents; } But this will work only in JavaSE7.0 and above.. sankar <a href="http://wisentechnologies.com/it-courses/java-training.aspx">java training in chennai</a>
try { Â ÂstaÂtemÂents; } catch (ExceÂptiÂonType e1) { Â ÂstaÂtemÂents; } catch (Exception e2) { Â ÂcatÂch-all statemÂents; } finally { Â ÂstaÂtemÂents; } We can write the above code like this also try { Â ÂstaÂtemÂents; } catch (ExceÂptiÂonType | Exception e1) { Â ÂstaÂtemÂents; } finally { Â ÂstaÂtemÂents; }
This is exactly what I need, thank you
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.