피드로 돌아가기
새로워지기·서른의 생활코딩

ex18) java_oop

NS
normalstory
표지 이미지




public class String01 {

public static void main(String[] args) {
String Str1;
Str1="korea"; //"korea"인문자열의 주소를 Str1이 받는다.
String Str2 = "korea"; //"korea"인문자열의 주소를 Str2이 받는다.
if(Str1==Str2){// 번지값 비교 
System.out.println("같다");
}else{
System.out.println("다르다");
}
String Str3 = new String ("Seoul"); //=String(String original) 
String Str4 = new String ("Seoul"); //=String(String original) 
//new로 선언하면 아무리 초기값이 같아도
//다른 객체(다른번지이다.)
if(Str3==Str4){// 번지값 비교 
System.out.println("같다");
}else{
System.out.println("다르다");
}
if(Str3.equals(Str4)){  // '=': 번지값 비교 ; 'equals' : 문자열 비교
         //단, string type이 라닌 경우 별도 재정의 하지않으면
 // Object 클래스 Equals() 함수의 기본처리: 번지값 비교 ;;재정의 필요.
System.out.println("같다");
}else{
System.out.println("다르다");
}
char []c={'A','B','C'};//문자형 상수
String Str5 = new String(c);//캐릭터 형을 객체정의함으로서 컨버팅 
System.out.println(Str5);//문자형 상수=>문자열 상수로 출력
System.out.println(Str5.toString());//문자열 상수로 출력

byte []b ={64,65,66}; //byte형 배열
String Str6 = new String(b,1,1); //string객체 정의 
System.out.println(Str6);//byte형->string객체 cast변환
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("문자열 s1:" +s1);
System.out.println("문자열 s1의 길이:" + s1.length());
System.out.println("문자열 s2 : " + s2);
System.out.println("문자열 s3 : " + s3.toString());
/*
byte aA[] = {80,85,83,65,78};
// 바이트 배열 생성
System.out.println("초기 바이트 배열 : {80,85,83,65,78}");
String aA1 = new String(aA,0);
// 바이트 배열을 문자열로 변환하여 객체 a1 생성
String aA2 = new String(aA,0,2,3);
// 부분 문자열 객체 a2 생성
System.out.println("byte형의 배열을 문자열로 변환 : " + aA1);
System.out.println("두 번째부터 세 개만 추출 : " + aA2);
**/
System.out.println("문자열을 쓰는 순간!:".length());
System.out.println("abcd!:".toUpperCase());
System.out.println("1"+"    abcd!  : ".trim()+"3");
int age = 20;
String o1 = "그의 나이는 " + age + "세 입니다."; // int 형의 데이터를 문자열로 변환하여 결합
System.out.println(o1); // "그의 나이는 20세입니다."를 출력
String o2 = "WorldCup " + 2 + 0 + 0 + 2;
System.out.println(o2); // "WorldCup 2002"를 출력
String o3 = "WorldCup " + (2 + 0 + 0 + 2);
System.out.println(o3); // "WorldCup 4"를 출력
String o4 = 2 + 0 + 0 + 2 + "WorldCup";
System.out.println(o4); // "4WorldCup"를 출력
String y1 = "WorldCup Korea";
System.out.println("추출된 문자 : " + y1.charAt(2));
char buff[] = new char[3];
y1.getChars(5,8,buff,0);  //5번지~8개->buff에 0번지부터(?)
System.out.println("추출된 문자열 : " + new String(buff));

String a01 = "알기쉽다." ;
String a02 = "Apple";
String a03 = "APPLE";
System.out.println("문자열 a1 : " + a01);
System.out.println("문자열 a2 : " + a02);
System.out.println("문자열 a3 : " + a03);
System.out.println("a1과 a2가 동일한 문자열? : " + a01.equals(a02));
System.out.println("a2와 a3가 동일한 문자열?(대소문자 무시) : "+ 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
친절한 찰쓰씨
글쓴이
친절한 찰쓰씨
친절한 찰쓰씨 · 일상 UX 디자이너
기획·디자인·단상을 조용히 기록합니다.
작가 페이지에서 더 보기

이어서 읽기

새로워지기

꾸준히, 오래, 지치지 않고

Mar 31, 2026·8
새로워지기

테크 라이프 발란스

Feb 7, 2026·3
새로워지기

휴탈리티 박정렬

Feb 7, 2026·11