token不允许啊,这样的话就要费一堆劲了
解决方案 »
- 对这段代码的运行顺序很糊涂,请大家帮忙!
- aaa|bbb|ccc|用replace怎么把|替换掉?
- access的驱动及连接
- 数据库驱动加载问题
- JLabe的setText方法不能及时显示的问题
- 父类和子类有一样的方法,如果要调用,会调用哪一个啊
- 问个JBuilder和java API的问题,我相信很多朋友都和我有一样的问题
- 天大发现!!!JDK 中提供的工具有问题!!!!!!!!!
- 问一个关于java.util.StringTokenizer 的问题?
- 如何从键盘读入一个double或int型数组??(高分!!)
- 再谈一个设计理念,献给所有想提高的java程序员!(续第一篇)
- mysql的jdbc驱动3.x版,不支持中文?
public class CutString
{
public static void main(String [] args)
{
String input=JOptionPane.showInputDialog("What is the String?");
int n=input.length();
int front=1;
int back=0;
back=input.indexOf("the");
while(back!=-1)
{
String tmp=input.substring(front-1,back);
System.out.println(tmp);
front=back;
front=front+4;
back=input.indexOf("the",front);
}
if(front<=(n-1))
{
System.out.println(input.substring(front-1,n));
}
System.exit(0);
}
}
写的有点不象话,但功能基本实现了
勉强看吧
输出在控制台
给分!!!!
{
public static void main(String[] args)
{
String S1="Once the firemen had put out the blaze, the other workers got busy.";
String S2="the";
while(S1.indexOf("the")!=-1)
{
System.out.println(S1.substring(0,S1.indexOf(S2)));
S1=S1.substring(S1.indexOf(S2)+S2.length(),S1.length());
}
System.out.println(S1);
}
}
while(S1.indexOf(S2)!=-1)
public class CutString
{
public static void main(String[] args)
{
String s1=JOptionPane.showInputDialog("input cut string:");
String s2=JOptionPane.showInputDialog("input string for cut:");
String s3=s2.replaceAll(s1,"\n");
System.out.println(s3);
}
}
public class CutString
{
public static void main(String[] args)
{
String s1=JOptionPane.showInputDialog("input cut string:");
String s2=JOptionPane.showInputDialog("input string for cut:");
String s3=s2.replaceAll(s1,"\n");
System.out.println(s3);
}
}
没看到只能用 indexOf和substring两个方法吗
{
int k = s1.indexOf(s2);
if(k != -1){ //included
System.out.print(s1.substring(0,k-1));
if(k+s2.length() < s1.length())
partition(s1.substring(k+s2.length(),s2.length()),s2);
}else
System.out.print(s1);
}
我觉得 foolfish(呆鱼) 的办法好~