public class Main01 {
public static void main(String[] args) {
String str1 = "자바 Programming";
String str2 = new String("Java");
System.out.println("str1 = " + str1);
System.out.println("str2 = " + str2);
System.out.println("------------------");
int str1_len = str1.length();
int str2_len = str2.length();
System.out.println("str1_length = " + str1_len);
System.out.println("str2_length = " + str2_len);
System.out.println("------------------");
int str1_position = str1.indexOf(" ");
int str2_position = str2.indexOf("a");
System.out.println("str1_position : " + str1_position);
System.out.println("str2_position : " + str2_position);
System.out.println("------------------");
int str1_last_position = str1.lastIndexOf(" ");
int str2_last_position = str2.lastIndexOf("a");
System.out.println("str1_last_position : " + str1_last_position);
System.out.println("str2_last_position : " + str2_last_position);
String new_str1 = str1.replace(" ","-");
String new_str2 = str2.replace("a","A");
System.out.println(new_str1);
System.out.println(new_str2);
System.out.println("------------------");
String upper_str1 = new_str1.toUpperCase();
String lower_str2 = new_str2.toLowerCase();
System.out.println("upper : "+ upper_str1);
System.out.println("lower : "+ lower_str2);
System.out.println("------------------");
String input = " enjoy java programming ";
String oupput = input.trim();
System.out.println("input : " + input);
System.out.println("output : " + oupput);
System.out.println("------------------");
String output2 = input.replace(" ","");
System.out.println("output2 : " + output2);
System.out.println("------------------");
boolean isSame = str1.equals(str2);
if (isSame) {System.out.println("같다");
}
else {System.out.println("다르다");
}
System.out.println("------------------");
String sub_str1 = str1.substring(0, 2);
String sub_str2 = str1.substring(3);
System.out.println(str1);
System.out.println("sub_str1 : " + sub_str1);
System.out.println("sub_str2 : " + sub_str2);
System.out.println("------------------");
int yy = 2023;
int mm = 2;
int dd = 1;
String gender = "남성";
String result = String.format("%d년 %02d월 %02d일 %s", yy,mm,dd,gender);
System.out.println(result);
System.out.println("------------------");
String src = "C++/Java/C#/Javascripit/VB";
String[] data = src.split("/");
for(int i= 0; i<data.length; i++) {
System.out.println(data[i]);
}
}
}