⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 substringexample.java

📁 java 完全探索的随书源码
💻 JAVA
字号:
public class SubstringExample{  // Default Constructor  public SubstringExample()  {    super();  }  // Method that actually performs the extraction  public String extractSubstring( String str1, int beginIndex, int endIndex )  {    return str1.substring( beginIndex, endIndex );  }  // Main Method  public static void main( String[] args )  {    if ( args.length != 3 )    {      System.out.println( "Usage: java StringCompareExample <String1> <String2>" );      System.exit( 0 );    }    String str = args[0];    String beginIndexStr = args[1];    String endIndexStr = args[2];    int beginIndex = 0;    int endIndex = 0;    // Make sure the arguments are valid    try    {      beginIndex = Integer.parseInt( beginIndexStr );      endIndex = Integer.parseInt( endIndexStr );    }    catch( NumberFormatException ex )    {      System.out.println( "The arguments are invalid" );    }    // Create an instance of the example    SubstringExample example = new SubstringExample();    // Get the strings passed in from the command line    // Inform the user what is going on    System.out.println( "Extrating from string: '" + str + "' starting at: " + beginIndex + " endIndex: " + endIndex );    // perform the comparison    String newSubstring =  example.extractSubstring( str, beginIndex, endIndex );    System.out.println( "Substring: " + newSubstring );  }}

⌨️ 快捷键说明

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