KonstrPZ_FPO_LR2014_4LR
.pdf*=0>4?.@.56 /6?0A0405 1?58/6.4-5925
*A-.//. Student
*/
public String toString(){ return fullName+" "+age;
}
}
/* ,-.// 012/34.56 ./12?.96.,
* B/12?.960C D785C 9.>34.6E /678596., 4310-9FG@5H0 95A060?7G 9.7I97G ?.D067
*/
public class Aspirant extends Student { //J.>4.925 9.7I90K ?.D063
private String workName;
public Aspirant(String fullName, int age, String workName) {
//=3>04 A09/6?7A60?. /715? A-.//. super(fullName, age); this.workName = workName;
}
public String getWorkName() { return workName;
}
public void setWorkName(String workName) { this.workName = workName;
}
public String toString(){
return super.toString() //=3>04 C5608. /715?A-.//.
+" "+workName;
}
}
Student student = new Student ("L56?59A0 M4H592K L56?042I",20); System.out.println(student.toString());
Aspirant apsirant = new Aspirant(";4.959A0 =-.82C2? ;4.9042I",25,"N.>?.D06A. C560804 0162C2>.O22 4 ?./1?585-5993P /2/65C.P");
System.out.println(apsirant.toString());
2.3 ! 5 3 5
2.3.12 B ,
m , '
/ .
2.3.2D B B
*.
2.3.3=B /i .
1. < B My, Main * IMy
.
2. =B B .
D B :
1.< * set get, B / / . 9 : *.
2.< * set get, B / / . 9 :
.
3.< * set get, B / / . 9 :
.
4.< * set get, B / / . 9 :
'.
5.< * set get, B / / . 9 :
.
6.< * set get, B / / . 9 : *.
7.< * set get,
B / / . 9 : .
8.< * set get,
B / / . 9 : .
9.< * set get, B / / . 9 :
.
10.< * set get, B / / . 9 :
.
3. < B Student Aspirant
. 2.2.4,
.
4. < (2–3 q.) ,
B
. < m B ,
B. 9 B
/ 2.
2.4 !5 L 5 <M
2.4.19 B.
2.4.2.
2.4.3. .
2.4.4. m, B /
B, B B B.
2.4.5 =B B, ' i B B B
(5 q. B ), ' ' /i B
q, .
2.5 4K 5
2.5.1/ * B?
2.5.2r / ?
2.5.3< * ' ?
2.5.4. / ?
2.5.5r B ?
2.5.6. B m ?
2.5.7= C ' public private?
2.5.8= B, F B *
' B?
2.5.9' ?
2.5.10r ?
3 A 1 1 1 A 3 : C
3.1 J54K
8 * B B
(B).
3.2 5 5 5 <5 3 5 5!5
= B B — B, B
* *.
=B B B – B, B B
* B ' *.
3.2.1 : 3 !
? * / .
= B / B, B /
q / , Scanner. 9 '
, q
* / m** B B B /
*.
€/ m PrintWriter,
B :
available() |
& B, |
|
* |
|
B. |
|
System.in.available() |
close() |
B . |
mark(int readlimit) |
? B readlimit |
|
B / m |
|
( *!) |
markSupported() |
&, ' m |
|
B mark() |
|
reset() |
read() |
< B /i |
|
|
read(byte [] b, [int off, int |
< B ( B len, |
len]) |
) b. H |
|
off B, m |
|
|
|
b. |
skip(long n) |
& B n |
|
* . |
9 ' B Scanner,
( B ' ):
close() |
B |
, |
B |
|
Scanner |
|
|
delimiter() |
= i i ( |
||
|
/ ) |
|
|
findInLine(String |
Di / , |
||
pattern) |
, |
||
|
(/i B m |
||
|
, B |
||
|
) , C null |
||
hasNext() |
& , /i |
||
|
– ( – ' |
||
|
) |
|
|
hasNext(String pattern) |
< |
|
|
hasNextBoolean() |
€ |
|
|
hasNextByte() |
† |
|
|
hasNextDouble() |
= i B double |
|
|
hasNextFloat() |
float |
|
|
hasNextInt() |
int |
|
|
hasNextLine() |
} iC |
||
hasNextLong() |
long |
|
|
hasNextShort() |
short |
|
|
next() |
& /i / ( |
||
|
). } |
||
|
/ next() |
||
|
B – / |
||
next(String pattern) |
} /i |
– |
|
|
* – , |
||||
|
/ |
|
|
|
|
nextBoolean() |
€/ / |
|
|||
nextByte() |
† |
|
|
|
|
nextDouble() |
Double |
|
|
|
|
nextFloat() |
Float |
|
|
|
|
nextInt() |
Int |
|
|
|
|
nextLine() |
€/ ( \n\f) |
|
|
|
|
nextLong() |
long |
|
|
|
|
nextShort() |
short |
|
|
|
|
useDelimiter(Pattern |
|
|
|
|
|
pattern) |
, |
' |
B |
… |
|
|
8, B ' B |
||||
|
(«1+2+3+4+5» : |
|
|||
|
MyScanner.useDeliniter(“-“); |
|
|||
|
While |
|
(MyScanner.hasNextInt()) |
||
|
System.out.print(MyScanner.nextInt); |
3.2.2 : 3 !
& B / B B B.
D * B * *
B (stream.close()), B (stream.flush()), m B B * (/ ).
= Java / B m
PrintStream, , , :
|
2 |
print(type value) |
=B / value, |
|
, |
|
8, System.out.print(“hello |
|
world!”) |
println(type value) |
=B / value, |
|
, c |
|
( ) /i / |
|
8, System.out.println(“hello |
|
world!”) |
printf([Locale l,] String |
=B *. |
format, Object... args) |
& * ' |
|
* |
|
|
|
8, System.out.printf( |
|
Locale.CHINA, '%tc', Date date ), |
|
B . * |
|
System.out.printf('%.3f', float f), |
|
B 3 |
|
( 1.5 |
|
1.500, 1.56789 – 1.567) |
checkError() |
&, B q |
|
B |
|
System.out.checkError() |
clearError() |
2 q q |
close() |
B . ? System.out |
|
B B ', |
|
, B |
flush() |
=B ' *. 9 * |
|
B * i. |
3.2.3 1 5 657 ! ! 3 4
? B B ' B
System.out.
? B Scanner. & B / :
import java.util.Scanner; // 7 7 :; public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in); // 9 L M : :; Scanner
int i = 2;
System.out.print("O 97 P ; 7 ;: ");
if(sc.hasNextInt()) { // Q 7 7 ;7 : 9
R 7 > P ; 7 ;
i = sc.nextInt(); // 7 < P ; 7 ; : 9 7 S
System.out.println(i*2); } else {
System.out.println("O< ;7 P ; 7 ;");
}
}
}
3.2.4 1 6 74
r * i i / ' Scanner,
System.in, FileInputStream.
2 F m :
FileInputStream in = new FileInputStream(filename) ;
9 ' B B PrintWriter, B
' *, System.out:
FileOutputStream outstream=new FileOutputStream(file) PrintWriter out = new PrintWriter(outstream);
= B, C * /
* B C : import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.IOException; import java.io.PrintWriter; import java.util.Scanner;
public class Main {
public static void main(String [] args) throws IOException
{
FileInputStream inputstream = new FileInputStream("src/in.txt");
Scanner input = new Scanner(in); FileOutputStream outstream = new
FileOutputStream("src/out.txt");
PrintWriter out = new PrintWriter(outstream); while (input.hasNext())
out.println(input.next());
input.close();
in.close();
out.close();
outstream.close();
}
}
1 :
1)2 B inputstream * («src/in.txt»);
2)< C i ( ) in;
3)2 B outstream * («src/out.txt»);
4)< C “PrintWriter” out outstream
5)& B B
outstream
6)B , B .
3.3 ! 5 3 5
3.3.12 B ,
m , '
/ .
3.3.2D B B
.
3.3.3=B /i :
1.< , B / .
2.< , B * «in.txt»
– , m
B * «out.txt»
D B :
1.8 , B
* B m, .
2.8 , B
' B
B i.
3.8 , B
* B m.
4.8 , B
*, C ' . D B *.
5.8 , B
B *.
6.8 , B *
B B m.
7.8 , B ' 5
B .
8.8 , B
B *
9.8 , B
B *
10.8 , B *
B B m.
3.4 !5 L 5 <M
3.4.19 B.
3.4.2.
3.4.3. .
3.4.4. m, B /
B, B B B.
3.4.5 =B B, ' i B B B
(5 q. B ), ' ' /i B
q, .
3.5 4K 5
1.r ?
2.r B?
r Scanner? & ?
3.r PrintWriter? & ?
4.r , B B
' m ?
5. . ' B /?
6. . ' «1*2*3*4*5»,
B / .
7. . ' * «01-02-2006»?