Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/367.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在功能上有什么挫败练习的目的?也许你应该想想函数的实际功能(或者看看JDK中的实现)并从中吸取教训。在不解决代码中的其他问题的情况下,最好在你努力工作并一路迭代之后返回i…:)到底是什么listArray?也是为了更好地阅读,通过快速查看标准的Knuth-_Java_For Loop_Indexof - Fatal编程技术网

Java 在功能上有什么挫败练习的目的?也许你应该想想函数的实际功能(或者看看JDK中的实现)并从中吸取教训。在不解决代码中的其他问题的情况下,最好在你努力工作并一路迭代之后返回i…:)到底是什么listArray?也是为了更好地阅读,通过快速查看标准的Knuth-

Java 在功能上有什么挫败练习的目的?也许你应该想想函数的实际功能(或者看看JDK中的实现)并从中吸取教训。在不解决代码中的其他问题的情况下,最好在你努力工作并一路迭代之后返回i…:)到底是什么listArray?也是为了更好地阅读,通过快速查看标准的Knuth-,java,for-loop,indexof,Java,For Loop,Indexof,在功能上有什么挫败练习的目的?也许你应该想想函数的实际功能(或者看看JDK中的实现)并从中吸取教训。在不解决代码中的其他问题的情况下,最好在你努力工作并一路迭代之后返回i…:)到底是什么listArray?也是为了更好地阅读,通过快速查看标准的Knuth-Morris-Pratt算法实现,了解equals的全部内容。indexOf方法总是返回字符串第一次出现的索引。我现在想知道为什么它只对返回值I起作用?为什么它不返回与其他索引相同的字符串?就像“hello”这个词一样,它首先出现在索引1,然后


在功能上有什么挫败练习的目的?也许你应该想想函数的实际功能(或者看看JDK中的实现)并从中吸取教训。在不解决代码中的其他问题的情况下,最好在你努力工作并一路迭代之后返回i…:)到底是什么
listArray
?也是为了更好地阅读,通过快速查看标准的Knuth-Morris-Pratt算法实现,了解
equals
的全部内容。indexOf方法总是返回字符串第一次出现的索引。我现在想知道为什么它只对返回值I起作用?为什么它不返回与其他索引相同的字符串?就像“hello”这个词一样,它首先出现在索引1,然后出现在索引3;这个方法将返回索引1。
public int indexOf(String str) {

    /*Getting and return the index of the first 
     *occurrence of the specified String. Return 
     *-1 if string not in the list
     */

    for(int i = 0; i < listArray.length; i++) {
        if(listArray[i].equals(str)) {
            return str.indexOf(listArray[i]);
        }
    }
    return -1;
}
public int indexOf(String str) {

    for(int i = 0; i < listArray.length; i++) {
        if(listArray[i].equals(str)) {
            return i;
        }
    }
    return -1;
}
for(int i=0;i<listArray.length;i++){
        if(listArray[i].equals(str)){
            return i;
        }
    }
return i;
public int indexOf(String str) {

    /* Getting and return the index of the first 
     * occurrence of the specified String. Return 
     * -1 if string not in the list
     */

    for (int i = 0; i < listArray.length; i++) {
        if (listArray[i].equals(str)) {
            // If we get here, it means that the item for position `i` is equal to `str`.
            return i; // just return `i` 
        }
    }

    return -1;
}
public int indexOf(String iparam){
    String astring = "" //YOUR OWN STRING
    boolean astat = false;
    List<Integer> alist = null;

    for(int i=0; i<astring.toCharArray().length; i++){
        alist = new ArrayList<>();
        for(int j=0; j<iparam.toCharArray().length; j++){
            try{
                if(astring.toCharArray()[i+j] == iparam.toCharArray()[j]){
                    alist.add(i+j);
                }else{
                    break;
                }
            }catch(Exception ex){
                ex.printStackTrace();
                break;
            }
        }
        if(alist.size() == iparam.toCharArray().length){
            astat = true;
            break;
        }
    }

    if(astat){
        return alist.get(0);
    }else{
        return -1;
    }
}