Java/디딤돌 Java 언어 Part1

[Java 소스] StringBuffer의 append 멤버 메서드 사용 예

언제나휴일 2017. 1. 4. 19:09
반응형

[Java 소스] StringBuffer의 append 멤버 메서드 사용 예


Program.java



//StringBuffer append 멤버 메서드 사용

public class Program {

        public static void main(String[] args){

               StringBuffer origin = new StringBuffer("abc");

              

               StringBuffer s1 = origin.append(true);

               System.out.println(s1);

               if(s1 == origin){

                       System.out.println("같은 개체 참조");

               }

               else{

                       System.out.println("다른 개체 참조");

               }

              

               origin.append('a');

               System.out.println(origin);

              

               char[] sarr = {'d','e','f','g','h'};

               origin.append(sarr);

               System.out.println(origin);

              

               origin.append(sarr,2,2);

               System.out.println(origin);

                             

               origin.append(3.14);

               System.out.println(origin);

              

               origin.append(3.14f);

               System.out.println(origin);

              

               origin.append(3);

               System.out.println(origin);

              

               origin.append(3l);

               System.out.println(origin);

              

               origin.append("Yahoo");

               System.out.println(origin);

        }

}


실행 결과

abctrue

서로 같다.

abctruea

abctrueadefgh

abctrueadefghfg

abctrueadefghfg3.14

abctrueadefghfg3.143.14

abctrueadefghfg3.143.143

abctrueadefghfg3.143.1433

abctrueadefghfg3.143.1433Yahoo



본문

[Java] 6.3.2 StringBuffer 클래스의 append 멤버 메서드

학습에 도움이 되시면 ebook 구입(판매가 3000, ebook)하여 소장하시면 감사하겠습니다.





반응형