Java String Instance Practice Example #1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
package edu.handong.csee.java.string;
public class FamilyNamePrinter{
private String[] stringNames;
private String[] familyNames;
public void printFamilyNames(){
for(String name: familyNames){
if(name == null){
System.out.print("");
}else{
System.out.println(name);
}
}
}
public FamilyNamePrinter(String names){
stringNames = names.split(",");
familyNames = new String[stringNames.length];
int i=0;
for(String name: stringNames)
familyNames[i++] = name.trim().split(" ")[1];
}
public static void main (String[] args) {
String myString = args[0];
FamilyNamePrinter myFamily = new FamilyNamePrinter(myString);
myFamily.printFamilyNames();
}
}
|
cs |
'Study > Java Programming' 카테고리의 다른 글
Deleting Duplicate Element Using HashSet (0) | 2019.04.28 |
---|---|
Java Usage ArrayList Example #1 (0) | 2019.04.28 |
Java programming practice; Tax (0) | 2018.10.06 |
Java Programming Practice #1 (0) | 2018.10.06 |
[Java Programming] Java return, 자바 리턴값 배우기 (0) | 2018.09.09 |