Title: e-mail : youjahn@gmail.com
1 ?? ?? ???? ?? ????
- ?? ?????? ??? ??
- ??? ??? 410?
- e-mail youjahn_at_gmail.com
2??? ??
- java.lang ???
- ???
- java.util ???? ???
31. java.lang ???
- Java.lang ???? ?????? ?? ??
Boolean Character Class ClassLoader Com
piler Byte Math Double Number Float Pro
cess Integer Object Runtime
Long SecurityManager
Short String StringBuffer System Thread
ThreadGroup Throwable void
4Object ???
- ?? ?? ????? ??? ???
- ?? ?? ????? ????. extends ???? ???? ????? ????
??? ???? - ?? ?? ?????? Object ???? ???? ???? ??
5Object ???
- Object ???? ?? ???
- Ojbect clone() ??? ???? ?? ???? ???
- boolean equals(Object object) ? ?? ??? ?? ?? ????
??? - true, ??? false? ??
- void finalize() ????? ??? ? ?? ???? ??? ?????
?? - ? ??(garbage collection)??? ????.
- finalize() ????
- ??? ?? ??? ???? ?? ???? ??? ????
- ?? ???? ????? ???? ???
- Class getClass() ??? ????? Class ?? ??? ??
- int hashCode() ??? ??? ??? hash ??? ???.
- String toString() ?? ??? ??? ??? ????
- void notify() ???? ??? ? ??? ????
?? ????? - void notifyAll() ???? ?? ???? ??
????? - void wait() ??? ???? ?? ??? ??
6??(Wrapper) ???
- 8?? ?? ??? ???? ??(wrapper) ???? ??
- ?? ???? ??? ???? ?? ????? ???? ??? ????? ??? ?
??. - ?? ???
- Boolean, Character, Byte, Short, Integer, Long,
- Float, Double
7??(Wrapper) ???
- ?? ???? ???? ?
- class ValueandWrapper
- public static void main(String args)
- int num1 20 // ?? num1 ?? ??
- Integer num2 new Integer(30)
- // Integer ?? ???? ???? ?? ?? num2? ??
- int total num1 num2.intValue()
- System.out.println("??? ?? " total)
-
8??(Wrapper) ??? - (1) Integer ???
- ???? ???? ???
- ???
- Integer(int n) // n ??? ?
- Integer(String str)
- // str ???(???? ??? ???? ??)
9??(Wrapper) ??? - (1) Integer ???
- Integer ???? ?? ???
- byte byteValue() ? ??? ?? byte ???
???? ?? - double doubleValue() ? ??? ?? double
??? ???? ?? - float floatValue() ? ??? ?? float
??? ???? ?? - int intValue() ? ??? ?? int ???
???? ?? - long longValue() ? ??? ?? long ???
???? ?? - short shortValue() ? ??? ?? short ???
???? ?? - String toString() ? ??? ?? ????
???? ?? - boolean equals(Object IntegerObj) ? ???
IntegerObj? ??? ??? ?? - ??? true, ??? false? ??
- static Integer decode(String str) ??? str? ????
Integer ??? ?? - throws NumberFormatException
- static int parseInt(String str) ??? str? ????
int ?? ?? - throws NumberFormatException
- static int parseInt(String str, int radix) ???
str? ???? int ?? radix? ??? throws
NumberFormatException ???? ??
10??(Wrapper) ??? - (2) Boolean???
- True ?? False ?? ???? ???
- ???
- Boolean(boolean b)
- Boolean(String s)
- b boolean ?? ?
- s boolean ?? ?? ?? ??? ???
- (true, false ?)
11??(Wrapper) ??? - (2) Boolean???
- Boolean ???? ???
- boolean booleanValue() ? ??? ?? boolean
??? ???? - ??
- boolean equals(Object boolObj) ? ??? boolObj?
??? ??? ?? - ??? true, ??? false? ??
- String toString() ? ??? ?? ????
?? - static boolean getBoolean(String str) ??? str?
???(? true ?? false) - ?? boolean ??? ??
- static Boolean valueOf(String str) ??? str? ???
?? Boolean ??? - ??
12??(Wrapper) ??? - (3) Character ???
- ???? ???? ???
- ???
- Character (char c)
-
- c char ?? ?
-
13??(Wrapper) ??? - (3) Character ???
- Character ???? ???
- static boolean isDefined(char ch) ch?
Unicode?? true ??? false? ?? - static boolean isDigit(char ch) ch? ????
true ??? false? ?? - static boolean isLetter(char ch) ch? ????
true ??? false? ?? - static boolean isLetterOrDigit(char ch) ch? ??
?? ???? true ??? false? - ??
- static boolean isLowerCase(char ch) ch? ?????
true ??? false? ?? - static boolean isSpace(char ch) ch? ?????? true
??? false? ?? - static boolean isUpperCase(char ch) ch? ?????
true ??? false? ?? - static char toLowerCase(char ch) ch? ??? ???
???? ???? ?? - static char toUpperCase(char ch) ch? ??? ???
???? ???? ??
14??(Wrapper) ??? - (3) Character ???
- ?
- class CharacterExam1
- public static void main(String args)
- char a 'a', 'b', ' ', '?', 'C', '5',
'A - for(int i0 ilta.length i)
- System.out.println("a" i " ?? ?? "
ai) - //??? true? ?? ??? ????? ????.
- if( Character.isDigit(ai) )
System.out.println(" ?????.") - if( Character.isLetter(ai) )
System.out.println(" ?????.") - if( Character.isSpace(ai) )
System.out.println(" ???????.") - if( Character.isUpperCase(ai) )
System.out.println(" ??????.") - if( Character.isLowerCase(ai) )
System.out.println(" ??????.") -
-
15??(Wrapper) ??? - (4) Byte ???
- byte?? ???? ???
- ???
- Byte(byte b)
- Byte(String s) throws NumberFormatException
- b byte? ?
- s byte ?? ?? ?? ???
- ???. S? byte ?? ???? ?? ??
- NumberFormatException ?? ??
16??(Wrapper) ??? - (4) Byte ???
- Byte ???? ???
- byte byteValue() ? ??? ?? byte ??? ???? ??
- double doubleValue() ? ??? ?? double ??? ???? ??
- float floatValue() ? ??? ?? float ??? ???? ??
- int intValue() ? ??? ?? int ??? ???? ??
- long longValue() ? ??? ?? long ??? ???? ??
- short shortValue() ? ??? ?? short ??? ???? ??
- String toString() ? ??? ?? ???? ???? ??
- boolean equals(Object BytesObj) ? ??? ??? ?? ??
BytesObj? ??? - ??? ??? ?? ?? ??? true, ???
- false? ??
- static Byte decode(String str) str? ??? ????
???? Byte ??? ?? - throws NumberFormatFxception
- static byte parseByte(String str) str? ??? ????
???? byte ?? ?? - throws NumberFormatException
- static byte parseByte(String str, int radix)
str? ??? ???? ???? byte ?? - throws NumberFormatException radix? ???
???? ??
17??(Wrapper) ??? - (5) Short ???
- Short?? ?? ???? ???
- ???
- Short(short s)
- Short(String str) throws NumberFormatException
- s short? ?
- str short ?? ?? ?? ??? ???
18??(Wrapper) ??? - (5) Short ???
- Short ???? ???
- byte byteValue() ? ??? ?? byte ??? ???? ??
- double doubleValue() ? ??? ?? double ???
???? ?? - short longValue() ? ??? ?? long ??? ???? ??
- float floatValue() ? ??? ?? float ??? ???? ??
- int intValue() ? ??? ?? int ??? ???? ??
- short shortValue() ? ??? ?? short ???
???? ?? - String toString() ? ??? ?? ???? ???? ??
- boolean equals(Object ShortObj) ? ??? ??? ?? ??
ShortObj? ??? - ??? ??? ?? ?? ??? true, ???
- false? ??
- static Short decode(String str) str? ??? ????
???? Short ??? ?? - throws NumberFormatException
- static short parseShort(String str) str? ???
???? ???? short ?? ?? - throws NumberFormatException
- static short parseShort(String str, int radix)
str? ??? ???? ???? short ?? throws
NumberFormatException radix? ??? ????
?? - static Short valueOf(String str) str? ??? ????
???? Short ??? - throws NumberFormatException ??
19??(Wrapper) ??? - (5) Short ???
- ?
- class ShortExam
- public static void main(String args)
- Short s1 new Short((short)100)
- short s2 Short.parseShort("20") //
?????? short ?? ?? ?? - int total s1.intValue() s2
- // Short ?? s1? ??? ?? ????
- // short ? ?? s2? ??? ?? ?? ??
- System.out.println("??? ?? " total)
- String mun "??? ??? ??? " s1.toString()
" ???" - System.out.println(mun)
-
20??(Wrapper) ??? - (6) Long ???
- long ?? ???? ???
- ???
- Long(long l)
- Long(String str) throws NumberFormatException
- l long ?? ?
- str long ?? ?? ?? ??? ???
21??(Wrapper) ??? - (6) Long ???
- Long ???? ???
- byte byteValue() ? ??? ?? byte ???
???? ?? - double doubleValue() ? ??? ?? double
??? ???? ?? - float floatValue() ? ??? ?? float
??? ???? ?? - short shortValue() ? ??? ?? short
??? ???? ?? - int intValue() ? ??? ?? int ???
???? ?? - long longValue() ? ??? ?? long ???
???? ?? - String toString() ? ??? ?? ???? ??
- boolean equals(Object LongObj) ? ??? ??? ?? ??
LongObj? ??? - ??? ??? ?? ?? ??? true, ???
- false? ??
- static long parseLong(String str) str? ??? ????
???? long ?? ?? - throws NumberFormatException
- static long parseLong(String str, int radix)
str? ??? ???? ???? long ?? - throws NumberFormatException
radix? ??? ???? ?? - static String toBinaryString(long num) num?
2? ??? ???? ?? - static String toHexString(long num) num?
16? ??? ???? ?? - static String toOctalString(long num) num?
8? ??? ???? ?? - static Long valueOf(String str) str? ??? ?? ???
Long ??? ??
22??(Wrapper) ??? - (6) Long ???
- ?
- class LongExam
- public static void main(String args)
- Long a new Long(100) // Long ?? a ??
- String st1 Long.toBinaryString(a.longValue
()) - // Long ?? a??? long ?? ???? 2? ???? ??
- System.out.println("long ? 100? ???? ?? "
st1) - String st2 Long.toHexString(a.longValue())
- // toHexString() ???? static?? ??? ???
?????? ??? ?? - // ? ?? ???? ??
- System.out.println("long ? 100? 16??? ??
" st2) - String st3 Long.toOctalString(a.longValue(
)) - System.out.println("long ? 100? 8??? ?? "
st3) -
-
23??(Wrapper) ??? - (7) Float ???
- float ?? ?? ???? ???
- ???
- Float(float f)
- Float(double d)
- Float(String str) throws
NumberFormatException - f,d float, double ?? ?
- str float ?? ?? ?? ??? ???
24??(Wrapper) ??? - (7) Float ???
- Float ???? ???
- byte byteValue() ? ??? ?? byte ??? ???? ??
- double doubleValue() ? ??? ?? double ??? ???? ??
- long longValue() ? ??? ?? long ??? ???? ??
- short shortValue() ? ??? ?? short ??? ???? ??
- float floatValue() ? ??? ?? float ??? ???? ??
- int intValue() ? ??? ?? int ??? ????
?? - String toString() ? ??? ?? ????
???? ?? - boolean equals(Object FloatObj) ? ??? ??? ?? ??
FloatObj? ??? - ??? ??? ?? ?? ??? true, ???
- false? ??
- boolean isNaN() ? ??? ??? ?? ??
NaN?? true, ??? - false? ??
- static boolean isNaN(float num) num? NaN??
true, ??? false? ?? - boolean isInfinite() ? ??? ??? ?? ??
NEGATIVE_INFINITY ?? - POSITIVE_INFINITY?? true, ???
false? ?? - static boolean isInfinite(float num) num?
NEGATIVE_INFINITY ?? - POSITIVE_INFINITY?? true, ???
- false? ??
25??(Wrapper) ??? - (8) Double ???
- double ?? ?? ???? ???
- ???
- Double(double d)
- Double(String str) throws NumberFormatException
- d double ?? ?
- str double ?? ?? ?? ??? ???
26??(Wrapper) ??? - (8) Double ???
- Double ???? ???
- byte byteValue() ? ??? ?? byte ??? ???? ??
- double doubleValue() ? ??? ?? double ??? ???? ??
- float floatValue() ? ??? ?? float ??? ???? ??
- int intValue() ? ??? ?? int ??? ???? ??
- short shortValue() ? ??? ?? short ??? ???? ??
- long longValue() ? ??? ?? long ??? ???? ??
- String toString() ? ??? ?? ???? ??
- boolean equals(Object DoubleObj) ? ??? ??? ?? ??
DoubleObj? - ??? ??? ??? ?? ?? ??? true,
- ??? false? ??
- boolean isNaN() ? ??? ??? ?? ?? NaN?? true, ???
- false? ??
- static boolean isNaN(double num) num? NaN??
true, ??? false? ?? - boolean isInfinite()? ??? ??? ?? ??
- NEGATIVE_INFINITY ??
- POSITIVE_INFINITY?? true, ???
- false? ??
- static boolean isInfinite(double num) num?
NEGATIVE_INFINITY ??
27??(Wrapper) ??? - Float ???? Double ???
- Float ???? Double ???? ??? ??? ???? ???.
- isInfinite() ??? ?? ???? ?? ??? ? ?? ?? ? true?
???? ??? - isNaN() ??? ??? ???(Not a Number) true? ????
??? - class InfNaN
- public static void main(String args)
- Double d1 new Double(0/0.)
- System.out.println("0/0. " d1 " "
d1.isInfinite() - ", "
d1.isNaN()) -
-
???? 0/0. NaN false, true
28??(Wrapper) ??? - (7) Float ???
- ?
- class FloatExam
- public static void main(String args)
- Float number new Float(10.0)
- System.out.println("? ??? ? " number)
- System.out.println("byte??? ?? "
number.byteValue()) - System.out.println("long??? ?? "
number.longValue()) - System.out.println("short??? ?? "
number.shortValue()) - System.out.println("int??? ?? "
number.intValue()) - System.out.println("double??? ??
(number.doubleValue())) - System.out.println("if NaN "
number.isNaN()) - System.out.println("if isInfinite "
number.isInfinite()) -
-
29??(Wrapper) ??? - (8)Double ???
- ?
- class DoubleExam
- public static void main(String args)
- double number1 0
- double number2 0
- double number3 number1/number2
- System.out.println("double?? ????? "
number3) - System.out.println("number3? ?? ??/?? ????
true/false? ? ? " Double.isInfinite(number
3)) - System.out.println("nember3? NaN? ??
true/false? ??
Double.isNaN(number3)) - System.out.println("Double? ??? "
Double.MAX_VALUE) - System.out.println("Double? ??? "
Double.MIN_VALUE) -
-
-
30Math ???
- ??? ??? ?? ??? ???? ???
- ???
- static int abs(int arg) arg?
???(absolute value)? int? ?? - static long abs(long arg) arg? ????
long?? ?? - static float abs(float arg) arg? ????
float? ?? - static double abs(double arg) arg? ????
double? ?? - static double ceil(double arg) arg?? ??? ??
?? ?? ??? ?? - static double floor(double arg) arg?? ??? ??
?? ? ??? ?? - static int max(int x, int y) x,y ? ?
? ?? int? ?? - static long max(long x, long y) x,y ? ? ? ??
long?? ?? - static float max(float x, float y) x,y ? ? ?
?? float? ?? - static double max(double x, double y) x,y ? ? ?
?? double? ?? - static int min(int x, int y) x,y ?
? ?? ?? int? ?? - static long min(long x, long y) x,y ? ? ??
?? long?? ?? - static float min(float x, float y) x,y ? ? ??
?? float? ?? - static double min(double x, doube y) x,y ? ? ??
?? double? ?? - static double rint(double arg) arg? ??
??? ??? ??
31Math ??? - ?
- class MathExam
- public static void main(String args)
- System.out.println("10 ??? "
Math.abs(10)) - System.out.println("10.0? ??? "
Math.abs(10L)) - System.out.println("20.0f? ??? "
Math.abs(20.0f)) - System.out.println("20.0d? ??? "
Math.abs(20.0d)) - System.out.println("? ?? ?????. "
Math.max(30, 60)) - System.out.println("?? ?? ?????. "
Math.min(10.0, 20.0)) -
-
322. ???
- ????? ???? ??? ??
- java.lang ???? ??
- java.lang.String ???? java.lang.StringBuffer ???
?? - String ??? ?? ??? ?? ??? ?? ???? ??
- StringBuffer ??? ???? ?? ? ?? ???? ??
33??? - String ???
- ???
- String()
- String(char chars)
- String(char chars, int startindex, int
numChars) - String(String strObj)
- String(byte asciiChars, byte highOrderByte)
- String(byte asciiChars, byte highOrderByte, int
startindex, int numChars) - String(byte asciiChars)
- String(byte asciiChars, int startIndex, int
numChars) - chars ?? ??
- startindex ?? ???? ???? ?? ??? ??? ?
- numChars startindex?? ???? ??? ?? ?? ???? ??
- asciiChars ??? ???? ???(ascii) ?? ??? ??
- highOrderByte ? ???(???, ?? ?)? ?? ???? ????
???, - ??? ??? ???? ???? 0? ??
34??? String ??? - ???? ???? ?
class StringExam1 public static void
main(String args) char a
'C','o','m','p','u','t','e','r String s1
new String(a) // ??????? ??? ?? s1 ??
String s2 new String(a,3,2) // ??????? ??
???? ???? s2 ?? String s3 new String("?? ??
??? Java") // ?????? ?? ?? s3 ??
System.out.println("??? s1 " s1)
System.out.println("??? s1? ?? "
s1.length()) System.out.println("??? s2 "
s2) System.out.println("??? s3 " s3)
35??? String ??? - ??? ??? ???? ???? ???? ?
class StringExam2 public static void
main(String args) byte a
80,85,83,65,78 // ??? ?? ??
System.out.println("?? ??? ??
80,85,83,65,78") String a1 new
String(a,0) // ?????? ???? ???? ??a1?? String
a2 new String(a,0,2,3) // ?? ??? ?? a2
?? System.out.println("byte?? ??? ???? ?? "
a1) System.out.println("? ???? ? ?? ?? "
a2)
36??? String ???
- String ???? ?? ???
- int length() ???? ??? ??
- char charAt(int i) ????? i?? ??? ??
- void getChars(int sourceStart, ???? ???
????(target)? ?? - int sourceEnd, char target,
- int targetStart)
- byte getBytes() ??? ???? ??? ??? ??
- boolean equals(Object str) ??? ???? str? ??? ????
??? true, - ??? false? ??
- boolean equalsIgnoreCase(String str) ??? ????
str? ??? ???? ??? true, - ??? false? ??. ?, ??? ????? ??
- boolean startsWith(String str) ??? ???? str?
???? true, ??? false? ?? - boolean endsWith(String str) ??? ???? str?
??? true, ??? false? ?? - int compareTo(String str) ? ?? ???? ???? ???
??, ??, 0? ?? ?? - int indexOf(char ch) ??? ??? ??? ?? ??????
ch? ??? ??? - ? ?? ???? ??
37??? String ???
- String ???? ?? ???(??)
- int indexOf(String str) ??? str? ? ?? ???? ??
- int indexOf(int ch, int startIndex) ???
startIndex ??? ?? ch? ? ?? ???? - ??
- int indexOf(String str, int startIndex) ???
startIndex ??? ??? str? ? ?? - ???? ??
- int lastindexOf(char ch) ?? ch? ??? ???? ??
- int lastindexOf(String str) ??? str? ??? ???? ??
- int lastindexOf(int ch, int startIndex) ???
startIndex ??? ?? ch? ??? ??? - int lastindexOf(String str, int startIndex) ???
startIndex ??? ??? str? ??? - ???? ??
- String substring(int startIndex)
startIndex??? ???? ?? ???? ?? - String substring(int startIndex, int
endIndex) startIndex? endIndex ??? ?? - ???? ??
- String concat(String str) ??? ???? str? ??? ????
?? - String replace(char original original? ??? ???
replacement? ??? - char replacement) ??? ??
38??? String ???
- String ???? ?? ???(??)
- String trim() ???? ? ? ??(whitespace)? ??
- static String valueOf(double num) num? ???? ????
?? - static String valueOf(long num) num? ???? ???? ??
- static String valueOf(Object obj) ??? ??? ?? ????
???? - ???? ??
- static String valueOf(char chars) ?? ??? ????
???? ?? - static String valueOf(char chars, ?? ??? ???
???? ???? ?? - int startIndex, int numChars)
- String toLowerCase() ???? ?? ???? ???? ??
- String toUpperCase() ???? ?? ???? ???? ??
39??? String ??? - (1) ???? ??
- ???
- int length() ???? ??? ??
- char chars 'K', 'o', 'r', 'e', 'a
- String s new String(chars)
- System.out.println(s.length())
??? 5? ??
40??? String ??? - (2) ???? ???? ?? ???? ??
New? ???? ?? ???? ??
- String s2 "2002 WorldCup Korea" // ????
??? ??? ?? - System.out.println("2002 Pusan Asiad".length())
- // String ?? ??? ?? ??? ???? ??? ? ??. 16? ??
- String age "20"
- String s "?? ??? " age "? ???."
- System.out.println(s) // "?? ??? 20????."? ??
???? ???? ???? ??
41??? String ??? - (2) ???? ???? ?? ???? ??
???? ?? ?? ?? ???? ???? ??
- int age 20
- String s1 "?? ??? " age "? ???."
- // int ?? ???? ????
???? ?? - System.out.println(s1) // "?? ???
20????."? ?? - String s2 "WorldCup " 2 0 1 0
- System.out.println(s2) //
"WorldCup 2010? ?? - String s3 "WorldCup " (2 0 1 0)
- System.out.println(s3) // "WorldCup
3? ??
42??? String ??? - (3) ?????? ?? ??
- ???
- char charAt(int i) ?????? i?? ??? ??
- void getChars(int sourceStart, int sourceEnd,
char target, int targetStart) - ???? ??? ?? ???(target)??.
43??? String ??? - (3) ?????? ?? ??
- ????? ??? ???? ?
- class StringExtract
- public static void main(String args)
- String a1 "WorldCup Korea"
- System.out.println("??? ?? "
a1.charAt(2)) - char buff new char3
- a1.getChars(5,8,buff,0)
- System.out.println("??? ??? " buff)
-
-
44??? String ??? - (4) ??? ??
- ???
- boolean equals(Object str)
- // str? ??? ???? ??? ???? ???? ??
- // ?) if (s1.equals(s2) ) ?? s1? s2?
??? true, ??? false - boolean equalsIgnoreCase(String str) // ???
??? ???? ?? - boolean startsWith(String str)
- // ??? ???? str? ??? ???? ???? true, ??? false?
?? - boolean endsWith(String str) // ???? str? ???
true, ??? false
45??? String ??? - (4) ??? ??
- class EqualsExam
- public static void main(String args)
- String a1 "????."
- String a2 "Apple"
- System.out.println("??? a1 " a1)
- System.out.println("??? a2 " a2)
-
- System.out.println("a1? a2? ??? ???? "
a1.equals(a2)) -
-
-
46??? String ??? - (4) ??? ??
- String s1 "WorldCup Korea"
- System.out.println(s1.startsWith("Wor")) //
true ?? - System.out.println(s1.endsWith("rea")) // true
??
47??? String ??? - (5) ??? ?? compareTo()
- ???
- int compareTo(String str)
- ??? ???? str? ??? ???? ????
- ??? ???? str? ??? ????? ??
- ??, ??? 0, ??? ???? ??.
- ??? ??? ??(???)? ?? ?? ??? ??
48??? String ??? - (6) ??? ??
- ?????? ??? ??? ?? ???? ???? ?? 2?? ??? ??.
- 2?? ???? ????? ??? ?? ???? ??? ??
- int indexOf(String str)
- int indexOf(int ch, int startIndex)
- int indexOf(String str, int startIndex)
- int lastindexOf(String str)
- int lastindexOf(int ch, int startIndex)
- int lastindexOf(String str, int startIndex)
49??? String ??? - (6) ??? ??
- class IndexExam
- public static void main(String args)
- String s "?? ?? ??? JAVA. " "java ??? ??
? java ???" - System.out.println(s)
- System.out.println("indexOf(?) "
s.indexOf('?')) - System.out.println("lastIndexOf(?) "
s.lastIndexOf('?')) - System.out.println("indexOf(a) "
s.indexOf("a")) - System.out.println("lastIndexOf(a) "
s.lastIndexOf("a")) - System.out.println("indexOf(a, 5) "
s.indexOf('a', 5)) - System.out.println("lastIndexOf(a, 40) "
s.lastIndexOf('a', 40)) - System.out.println("indexOf(java, 10) "
s.indexOf("java", 10)) - System.out.println("lastIndexOf(java, 40) "
s.lastIndexOf("java", 40)) -
-
-
50??? String ??? - (7) ???? ??
- String ???? ??? ??? ???? ??? ? ??. String ????
??? ???? ???? ??? ???? ???? ???? ???? - ???
- String substring(int startIndex, int endIndex)
?? ???? ?? - String concat(String constr) ??? ??? ??
- String replace(char original, char replacement)
??? ??? ?? - String trim() ???? ??? ???? ?? ??? ???
- ???? ??
51??? String ??? - (7) ???? ??
- class SubStringExam
- public static void main(String args)
- String str "?? ?? ??? ??"
- System.out.println("??? 5?? 8 ????? ?? "
str.substring(5,8)) - System.out.println( str.concat("? ?? ????")
) - System.out.println(str.replace('?','?'))
- str " " str " " // ?? 2?, ??
5?? ?? ?? - System.out.println("?? ?? str? ?? "
str.length()) - str str.trim() // ???? ?? ???
?? - System.out.println("?? ?? str? ??
str.length()) -
52??? String ??? - (8) ? ??
- ?? ?? ???? ???? ???? ???
- static String valueOf(double num)
- static String valueOf(long num)
- static String valueOf(Object obj)
- static String valueOf(char chars)
- static String valueOf(char chars, int
startIndex, int numChars) - ????? ?? ???.
- String toLowerCase()
- String toUpperCase()
53??? String ??? - (8) ? ??
- class ConvertString
- public static void main(String args)
- int a 2002
- char b 'W','o','r', l'
,'d','c','u','p - System.out.println(String.valueOf(a) " "
String.valueOf(b) - "? ????....")
- String s1 String.valueOf(b)
- // valueOf() ???? static?? ??? ??? ???
- System.out.println(String.valueOf(a) " "
s1.toUpperCase() - "? ????....")
-
-
54??? StringBuffer ???
- ?? ? ?? ???? ???
- ???
- StringBuffer() ????? 16?? ??? ??? ? ?? ??? ??
- StringBuffer(int size) size ??? ??? ??
- StringBuffer(String str) str? ??? ???? ??? 16??
??? - ? ???
? ?? ??? ?? - StringBuffer ??? ??? ??? ?? ? ?? ???? ? ????(16??
??? ??? ? ?? ?? ???)
55??? StringBuffer ???
- StringBuffer ???? ???
- StringBuffer append(boolean b) b? ??? ??? ??
?? - StringBuffer append(char ch) ch? ??? ???
?? ?? - StringBuffer append(double d) d? ??? ??? ??
?? - StringBuffer append(float f) f? ??? ???
?? ?? - StringBuffer append(int i) i? ??? ???
?? ?? - StringBuffer append(long l) l? ??? ???
?? ?? - StringBuffer append(Object obj) obj? ?? ????
??? ??? ?? ?? - StringBuffer append(String str) str? ??? ???
?? ?? - int capacity() ??? ??? ???
??? ?? - char charAt(int i) i ?? ????
???? ??? ?? - StringBuffer insert(int i, boolean b) i ?? ???
?? b? ?? - StringBuffer insert(int i, char ch) i ?? ???
?? ch? ?? - StringBuffer insert(int i, int j)
i ?? ??? ?? j? ??
56??? StringBuffer ???
- StringBuffer ???? ???
- StringBuffer insert(int i, long l) i ??
??? ?? l? ?? - StringBuffer insert(int i, Object obj) i ??
??? ?? obj? ?? - StringBuffer insert(int i, String str) i ??
??? ?? str? ?? - int length() ??? ???
?? ??? ??? ?? - StringBuffer reverse() ????
??? ???? ???? ?? - void setCharAt(int i, char ch) i ??
??? ch? ?? - void setLength(int len) ??? ???
len ??? ?? - String toString() ??? ????
String ??? ??
57??? StringBuffer ??? - ?
- class StringBufferExam1
- public static void main(String args)
- StringBuffer str1 new StringBuffer("Hello
JAVA") - StringBuffer str2 new StringBuffer("?????
??") - System.out.println("??1 ?? gt " str1)
- System.out.println("??1 ?? gt "
str1.length()) - System.out.println("??1 ?? gt "
str1.capacity()) - // ?? ???? 16? ? ??? ???.
- System.out.println("??2 ?? gt " str2)
- System.out.println("??2 ?? gt "
str2.length()) - System.out.println("??2 ?? gt "
str2.capacity()) -
-
-
58??? StringBuffer ??? - ?
- class StringBufferExam2
- public static void main(String args)
- StringBuffer str1 new StringBuffer("??
??") - System.out.println("??? ???? ?? gt " str1)
- System.out.println("??? ???? gt "
str1.insert(3,"Power ")) - System.out.println("5?? ??? ?? gt "
str1.charAt(4)) - str1.setCharAt(0, '?') // 0?? ???? ??
'?'?? ?? - str1.setLength(8) // ???? ??? 8? ??. ????
?? - System.out.println("??? ??? ? gt " str1)
- System.out.println("???? ?????? gt "
str1.reverse()) -
-
59??? String ??? ??
- ??? String ?????? ?? ??? ??? ??? ??
- class StringConvert1
- public static void main(String args)
- String s1 "? ?? "
- String s2 "?? ??"
- s1 s1 s2
- System.out.println(s1)
- class StringConvert2
- public static void main(String args)
- StringBuffer s1 new StringBuffer("? ?? ")
- s1.append("?? ??")
- System.out.println(s1)
-
? ??? ????? ?? ??? ????
603. java.util ???? ???
61 ???? ??? Random ???
- ?? ?? ?? ??
- double, float, int, long ? ??? ??? ?? ??
- ???
- Random() // ??? ??? ????? ?? ??
?? - Random(long seed) // seed ?? ????? ?? ?? ??
62???? ??? Random ???
- Random ???? ?? ???
- void nextBytes(byte buffer) buffer? ??? ???
- float nextFloat() float ?? ??? ??
- int nextInt() int ?? ??? ??
- long getLong() long ?? ??? ??
- double nextDouble() double ?? ??? ??
- double nextGaussian() Gaussian ?? ???
double ??? ?? - void setSeed(long newseed) ?? ???? seed ??
newseed ??? - ??
63???? ??? Date ???
- ??? ??? ?? ??? ???? ???
- ???
- Date()
- Date(long msec)
- Date(int year, int month, int day)
- Date(int year, int month, int day, int hours, int
minutes) - Date(int year, int month, int day, int hours, int
minutes, int seconds) - Date() ??? ??? ??? ?? ??? ??
- Date(long msec) GMT(Greenwich Mean Time)
??(1970? 1? 1? ??)?? - msec ???? ??? ??? ?? ??? ??
- ??? ????? ?, ?, ? ?? ???? Date ??? ??
64???? ??? Date ???
- Date ???? ?? ???
- boolean after(Date d) d? ??? ??? ?? ?? ???? true,
??? false? ?? - boolean before(Date d) d? ??? ??? ?? ?? ????
true, ??? false? ?? - boolean equals(Date d) d? ??? ??? ??? ??? ???
true, ??? false? ?? - long getTime() 1970? ??? ????? ???
???? ?? - int getDate() 1-31 ??? ??? ??
- int getDay ??? ???? ??? ??.
0???-6??? - int getHours() 0-23??? ??? ??
- int getMinutes 0-59 ??? ?? ??
- int getSeconds() 0-59 ??? ?? ??
- int getMonth() ???? ?? ??.
01?-1112? - int getYear() 1900? ????? ??? ??
- void setTime(long msec) ?? ??? ??? ??? 1970?
??? msec? ?? - void setDate(int day) ??? ??
- void setHours(int hours) ??? ??(0-23)
- void setMinutes(int minutes) ?? ??
- void setSeconds(int seconds) ?? ??
- void setYear(int year) ???? (1900?? ???? ??
??. ? 50?? 1950??? - String toString() ??? ??? ???? ??
65???? ??? Stack ???
- Vector ???? ?? ????? LIFO(Last-In First-Out) ???
?? ???? - ???
- boolean empty() ??? ?? ??? true, ??? false? ??
- Object peek() ?? top ?? ??. ??? ?? ??
- throws EmptyStackException
- Object pop() ?? top ?? ???? ???
- throws EmptyStackException
- Object push(Object obj) obj? ??? top? ??? ?? ??
- int search(Object obj) ???? obj? ?? ???? ??.
- top? ???? 1??. obj? ??? -1? ??