master String class

Today our high-end,Domineering,high grade(高端霸气上档次)1027 group strat its first voyage.(please forgive me for decribing our group with so many adj)Now let's talk about the technology problem.
1:basic data type (eight)
2:String class
* 1.byte -128~127
* 2.short -2^32~2^32-1
* 3.int -4 bit~4 bit -1
* 4.long -8 bit~8 bit -1
* floating-point type(both are plus-minus)
* 5.float -16 bit~16 bit-1
* 6.double -32 bit~32 bit-1
* char type(only plus)
* 7.char 0~16 bit-1
* only true and false(boolean)
* 8.boolean true or false
* @author Administrator
be careful:the range of the data
type a=128;
type b=(type)a;(b=-128)

mission statistic every number of char's appearence code

public class homework0703 {
public static void main(String[] args){
//define the string
String sa="euriyui3743289^%^&*&DJHK2312";
homework0703 ho=new homework0703();
//use statistics way
ho.statistics(sa);

}
public void statistics(String a){
//turn the string into char array
char sa[]=a.toCharArray();
int k=a.length();
//define other two array to store char and number
char sb[]=new char[k];//statistic the char
int sc[]=new int[k];//statistic the char number
int N=0;//counter
//search char from zero to k
for(int i=0;i<k;i++){
boolean NB=true;


//exam whether the char has appeared before or not
for(int j=0;j<i;j++){
if(sa[j]==sa[i])
NB=false;
}

if(NB)
{ sb[N]=sa[i];//assignment sa[] to sb[];
sc[N]=0;
//calculate the number of the char N
for(int p=i;p<k;p++){
if(sa[p]==sb[N]){
sc[N]++;
}
}
N++;
}


}
for(int i=0;i<N;i++){
System.out.print(sb[i]+" ");
System.out.println(sc[i]);
}


}
}

just use the "toCharArray()" way and array
later on,i will improve it and try to use as many ways as possible in the String class.And by reaching to API frequently,i feel like i am gradually comprehending how to use it.There are still many problem in How to use String class flexible,but i think you can get the answer in the API which is incrediable useful.So tonight let's end with the famous saying "there always start with a big-bang".
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值