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

📄 indexofexample.java

📁 java 完全探索的随书源码
💻 JAVA
字号:
public class IndexOfExample{  // Default Constructor  public IndexOfExample()  {    super();  }  // Method that actually performs the search  public int doSearch( String str, String subStr )  {    return str.indexOf( subStr );  }  // Main Method  public static void main( String[] args )  {    if ( args.length != 2 )    {      System.out.println( "Usage: java IndexOfExample <String> <Substring>" );      System.exit( 0 );    }    // Create an instance of the example    IndexOfExample example = new IndexOfExample();    // Get the strings passed in from the command line    String str = args[0];    String subStr = args[1];    // Inform the user what is going on    System.out.println( "Searching string: " + str + " for: " + subStr );    // perform the search    int index = example.doSearch( str, subStr );    // check the result    if ( index != -1 )    {      System.out.println( "Found the substring at position " + index );    }    else    {      System.out.println( "Did not find the substring" );    }  }}

⌨️ 快捷键说明

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