public class String01 {
public static void main(String[] args) {
String Str1;
Str1="korea"; //"korea"ofstring address Str1
String Str2 = "korea"; //"korea"ofstring address Str2
if(Str1==Str2){// address comparison
System.out.println("equal");
}else{
System.out.println("different");
}
String Str3 = new String ("Seoul"); //=String(String original)
String Str4 = new String ("Seoul"); //=String(String original)
//new declaration no matter initialvalue even if same
//other object(otheraddress.)
if(Str3==Str4){// address comparison
System.out.println("equal");
}else{
System.out.println("different");
}
if(Str3.equals(Str4)){ // '=': address comparison ; 'equals' : string comparison
//however, string type not case separate re-definition if not
// Object class Equals() function basichandling: address comparison ;;re-definition needed.
System.out.println("equal");
}else{
System.out.println("different");
}
char []c={'A','B','C'};//charactertype constant
String Str5 = new String(c);//character type objectdefinitionby doing converting
System.out.println(Str5);//charactertype constant=>string constant output to
System.out.println(Str5.toString());//string constant output to
byte []b ={64,65,66}; //bytetype array
String Str6 = new String(b,1,1); //stringobject definition
System.out.println(Str6);//bytetype->stringobject cast conversion
char a[]={'C','o','m','p','u','t','e','r'};
String s1 = new String(a);
String s2 = new String(a,3,2);
String s3 = new String("hello JAVA");
System.out.println("string s1:" +s1);
System.out.println("string s1 length:" + s1.length());
System.out.println("string s2 : " + s2);
System.out.println("string s3 : " + s3.toString());
/*
byte aA[] = {80,85,83,65,78};
// byte array creation
System.out.println("initial byte array : {80,85,83,65,78}");
String aA1 = new String(aA,0);
// byte array string conversion by object a1 creation
String aA2 = new String(aA,0,2,3);
// partial string object a2 creation
System.out.println("bytetype's array string conversion : " + aA1);
System.out.println("from the 2nd, 3 nly : " + aA2);
**/
System.out.println("string !:".length());
System.out.println("abcd!:".toUpperCase());
System.out.println("1"+" abcd! : ".trim()+"3");
int age = 20;
String o1 = "that's " + age + " ."; // int type's data string conversion by
System.out.println(o1); // "that's 20." output
String o2 = "WorldCup " + 2 + 0 + 0 + 2;
System.out.println(o2); // "WorldCup 2002" output
String o3 = "WorldCup " + (2 + 0 + 0 + 2);
System.out.println(o3); // "WorldCup 4" output
String o4 = 2 + 0 + 0 + 2 + "WorldCup";
System.out.println(o4); // "4WorldCup" output
String y1 = "WorldCup Korea";
System.out.println(" character : " + y1.charAt(2));
char buff[] = new char[3];
y1.getChars(5,8,buff,0); //5address~8->buff 0address(?)
System.out.println(" string : " + new String(buff));
String a01 = "know." ;
String a02 = "Apple";
String a03 = "APPLE";
System.out.println("string a1 : " + a01);
System.out.println("string a2 : " + a02);
System.out.println("string a3 : " + a03);
System.out.println("a1 a2 occurrence string? : " + a01.equals(a02));
System.out.println("a2 a3 occurrence string?(character un) : "+ a02.equalsIgnoreCase(a03));
}
}
- Open in Google Docs Viewer
- Open link in new tab
- Open link in new window
- Open link in new incognito window
- Download file
- Copy link address
- Edit PDF File on PDFescape.com
element
| Font | |
|---|---|
| font-family | |
| font-size | |
| font-style | |
| font-variant | |
| font-weight | |
| letter-spacing | |
| line-height | |
| text-decoration | |
| text-align | |
| text-indent | |
| text-transform | |
| white-space | |
| word-spacing | |
| color | |
| Background | |
| bg-attachment | |
| bg-color | |
| bg-image | |
| bg-position | |
| bg-repeat | |
| Box | |
| width | |
| height | |
| border-top | |
| border-right | |
| border-bottom | |
| border-left | |
| margin | |
| padding | |
| max-height | |
| min-height | |
| max-width | |
| min-width | |
| outline-color | |
| outline-style | |
| outline-width | |
| Positioning | |
| position | |
| top | |
| bottom | |
| right | |
| left | |
| float | |
| display | |
| clear | |
| z-index | |
| List | |
| list-style-image | |
| list-style-type | |
| list-style-position | |
| Table | |
| vertical-align | |
| border-collapse | |
| border-spacing | |
| caption-side | |
| empty-cells | |
| table-layout | |
| Effects | |
| text-shadow | |
| -webkit-box-shadow | |
| border-radius | |
| Other | |
| overflow | |
| cursor | |
| visibility |
