小编cch*_*hua的帖子

如何删除句子中的一些单词Java?

假设字符串是:

The/at Fulton/np-tl County/nn-tl Grand/jj-tl

如何删除后面/和下面的字符如下所示 The Fulton County Grand

java string

3
推荐指数
2
解决办法
2856
查看次数

对于循环仅循环1次JAVA?

我有一个for循环方法的问题,只有循环1次是什么问题?在数组中没有任何问题,它能够打印我想要的值.

这是我的代码:

public static void main(String[] args){

        String s = "Apple0, Apple1, Apple2, Apple3, Apple4";
        String[] word = s.split(",");
        StringBuffer str = new StringBuffer();
        Integer total = 0;

        for (int y = 0; y < word.length; y++){
            if(word[y].toString().equals("Apple2") ){
                total++;
                //str.append(word[y].toString());
            }else if(word[y].toString().equals("Apple3") ){
                total++;
                //str.append(word[y].toString());
            }else if(word[y].toString().equals("Apple4") ){
                total++;
                //str.append(word[y].toString());
            }
            else if(word[y].toString().equals("Apple1") ){
                total++;
                //str.append(word[y].toString());
            }


    }
        System.out.println( word[0] + word[1] + word[2] +  word[3] + word[4] + word.length);
        System.out.println(str + "hihi" + total);

}
Run Code Online (Sandbox Code Playgroud)

java loops for-loop

3
推荐指数
1
解决办法
329
查看次数

如何将句子分成Java部分?

我怎么可以把类似的句子"He and his brother playing football."成几部分一样"He and","and his","his brother","brother playing""playing football".是否可以通过使用Java来实现?

java string sentence

2
推荐指数
1
解决办法
1万
查看次数

如何在文本文件中获取句子并将其放入数组列表Java?

假设文本文件包含:

He is a boy .
She is sick .
Ali is playing .
We are eating .
The dog is barking .
He and his brother are running .
Run Code Online (Sandbox Code Playgroud)

如何将所有句子放入数组列表格式:

He is
is a 
a boy
boy .
She is
is sick
sick .
Run Code Online (Sandbox Code Playgroud)

等等.

我使用数组列表来避免继续读取文本文件来执行某些任务是否可能?或者我需要使用vector来做到这一点?

java string vector arraylist

1
推荐指数
1
解决办法
2860
查看次数

标签 统计

java ×4

string ×3

arraylist ×1

for-loop ×1

loops ×1

sentence ×1

vector ×1