作者在 2010-05-16 15:35:09 发布以下内容
~~~~~~~~~~~~~~~~~~~~··
package com.yds.text4;
import java.util.StringTokenizer;
public class StringTokenizeor {
/**
* @param args
*/
public static void main(String[] args) {
String m="I am a stud,ents";
StringTokenizer st=new StringTokenizer(m," ,");//将字段串按空格和逗号分开
while(st.hasMoreTokens()){//直到最后一个字符串,返回false
String str=st.nextToken();//找到下一个字符串
System.out.println(str);
}
* @param args
*/
public static void main(String[] args) {
String m="I am a stud,ents";
StringTokenizer st=new StringTokenizer(m," ,");//将字段串按空格和逗号分开
while(st.hasMoreTokens()){//直到最后一个字符串,返回false
String str=st.nextToken();//找到下一个字符串
System.out.println(str);
}
}
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~··
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~··
package com.yds.text4;
public class NumberTet {
/**
* @param args
*/
public static void main(String[] args) {
int number=342;
String n= Long.toBinaryString(number);
System.out.println(number+"的二进制"+n);
System.out.println(number+"的十六进制"+Long.toString(number,16));
System.out.println(number+"的八进制"+Long.toString(number,8));
int wn=0,mn=0;
for(int i=n.length()-1;i>=0;i--){
char m=n.charAt(i);
int w=Integer.parseInt(m+"");
wn=(int) (wn+(w*Math.pow(2,mn)));//将二进制转化成十进制
mn++;
}
System.out.println(wn);
}
* @param args
*/
public static void main(String[] args) {
int number=342;
String n= Long.toBinaryString(number);
System.out.println(number+"的二进制"+n);
System.out.println(number+"的十六进制"+Long.toString(number,16));
System.out.println(number+"的八进制"+Long.toString(number,8));
int wn=0,mn=0;
for(int i=n.length()-1;i>=0;i--){
char m=n.charAt(i);
int w=Integer.parseInt(m+"");
wn=(int) (wn+(w*Math.pow(2,mn)));//将二进制转化成十进制
mn++;
}
System.out.println(wn);
}
}