我有一个字符串,我应该在课程中使用 StringTokenizer。我已经制定了如何实施该项目的计划,但我找不到任何关于如何为每个字符设置分隔符的参考。
基本上,像“Hippo Campus is a party place”这样的字符串,我需要为每个字符划分标记,然后将它们与一组值进行比较,然后将特定的值与另一个值交换。我知道如何做其他所有事情,但是分隔每个字符的分隔符是什么?
所以,我输入了两个字符串,并且在mString中查找了subString.当我将方法更改为boolean时,它返回true或false的正确输出(通过在contains语句上使用return).
我不知道如何使用该语句来检查包含运算符的结果.我完成了以下工作.
public class CheckingString
{
public static void main(String[] args)
{
// adding boolean value to indicate false or true
boolean check;
// scanner set up and input of two Strings (mString and subString)
Scanner scan = new Scanner(System.in);
System.out.println("What is the long string you want to enter? ");
String mString = scan.nextLine();
System.out.println("What is the short string that will be looked for in the long string? ");
String subString = scan.nextLine();
// using the 'contain' operator to move …Run Code Online (Sandbox Code Playgroud)