teststring.java

来自「我在学校写的assignment,是一个java-based 实时通讯工具。 用」· Java 代码 · 共 41 行

JAVA
41
字号
import java.io.*;


public class TestString
{

	public static void main(String args[])
	{
		String temp = "hi, :$:happy:$: i am tom:$:sad:$:adafaf.";
		
		System.out.println(temp);
		//for (int i = 0; i < temp.length() ; i++)
		//{
			System.out.println( temp.indexOf(":$:", 0)); 
		//}
		
		int i = 0;
		int firstIndex = -1;
		
		while (temp.indexOf(":$:", i) != -1)
		{
			System.out.println("Loop");
			firstIndex = temp.indexOf(":$:", i);
			
			i = firstIndex + 3; 	//becuase the string is ":$"
			
			if (temp.indexOf(":$:", i) != -1)
			{
				System.out.println(temp.substring(0, firstIndex ));
			
				System.out.println(temp.substring(i, temp.indexOf(":$:", i)));
				
				temp = temp.substring(temp.indexOf(":$:", i) + 3);
				
				System.out.println(temp);
				
			}
		}	
			
	}
}	

⌨️ 快捷键说明

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