random 练习

package com.sk.skkill;

import com.sun.media.jfxmediaimpl.HostUtils;
import org.junit.jupiter.api.Test;

import java.util.*;

public class demo
{

@Test
public void xunhuan()
{
int num=10;
while (num<=100){


System.out.println(num);

num++;
if(num%6==0)
{

continue;
}
}
System.out.println("统计次数:"+(num));

}

@Test
public void character(){
Character character=new Character('a');
System.out.println(character);
System.out.println(character.compareTo('a'));
System.out.println(character.compareTo('b'));
System.out.println(character.isLetter('1'));
System.out.println(character.isUpperCase('T'));

}

@Test
public void str(){
char [] arr ={'H','e','l','l','o'};
String zf ="人生苦短,我学python";
System.out.println(zf);
System.out.println(arr);
String string =new String(arr);
System.out.println(string);
System.out.println(arr.equals(string));
System.out.println(zf.substring(3,6));//截取3---6 其实是5
System.out.println(string.split(",",1));
System.out.println(string.indexOf("e"));//获取下标1
System.out.println(string.charAt(1));//获取下标1的值 e
System.out.println(zf.concat("。。。"+string));//拼接字符串
System.out.println(zf.contentEquals(string));
System.out.println(string.toUpperCase());
char [] rd ={97};
Arrays.sort(rd);
System.out.println(rd);

int num =97;
for (int i=0;num<122+1;i++){

Random random=new Random();

char sjchar = (char)random.nextInt(num);
int sjint=random.nextInt(num);

System.out.println("随机后的数字:"+sjint);
System.out.println("随机后转换的字母:"+sjchar);
System.out.println();
System.out.println("-----------------\n");
System.out.println(num+"\t"+"对应的字母\t"+(char) num);
char charst =(char) num;
String uppCase = String.valueOf(charst);
System.out.println(num+"\t"+"对应的大写字母\t"+uppCase.toUpperCase());
num++;
}


}
@Test
public void collection()
{
String array [] ={"明天会更好","为你写诗","宁夏","下一个天亮","梦醒时分","光阴的故事"};
for(String item:array){
System.out.println(item);
}
List list =new ArrayList();
for (int i=0;i
list.add(String.valueOf(array[i]) );//数组转换称string


}
System.out.println(list);
System.out.println(list.equals("江南"));
System.out.println(list.get(2));


}



@Test
public void whiles(){
int num =100;
int nums=0;
int sum= 0;
while (num>10)
{
System.out.println(num);
num--;
}
System.out.println("------------------------");
while (nums<10)
{
nums++;

sum +=nums;
System.out.println(sum);

}

}

}




你可能感兴趣的:(random 练习)