stringconcat.java

来自「金旭亮的java教案」· Java 代码 · 共 30 行

JAVA
30
字号
// StringConcat.java
// This program demonstrates the String class concat method.
// Note that the concat method returns a new String object. It
// does not modify the object that invoked the concat method.
import javax.swing.*;

public class StringConcat {
   public static void main( String args[] )
   {
      String s1 = new String( "Happy " ),
             s2 = new String( "Birthday" ),
             output;

      output = "s1 = " + s1 +
               "\ns2 = " + s2;

      output += "\n\nResult of s1.concat( s2 ) = " +
                s1.concat( s2 );

      output += "\ns1 after concatenation = " + s1;

      JOptionPane.showMessageDialog( null, output,
         "Demonstrating String Method concat",
         JOptionPane.INFORMATION_MESSAGE );

      System.exit( 0 );
   }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?