stringhashcode.java

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

JAVA
29
字号
// StringHashCode.java
// This program demonstrates the method 
// hashCode of the String class.


import javax.swing.*;

public class StringHashCode {
   public static void main( String args[] )
   {
      String s1 = "hello",
             s2 = "Hello";


      String output =
         "The hash code for \"" + s1 + "\" is " +
         s1.hashCode() + 
         "\nThe hash code for \"" + s2 + "\" is " +
         s2.hashCode();

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

      System.exit( 0 );
   }
}

⌨️ 快捷键说明

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