展开全部
public class CharCount {
public static void main(String[] args){
int count = 0;
String str = "gfjsjgperjtpojewrjopeqjwrio34rengflkajsaljfrajfasnflanfla";
for(int i = 0; i < str.length(); i++){
if(str.charAt(i)=='j'){
count++;
}
}
System.out.println(count);
}
}
扩展资料:
Java常见字符:
int 型
常量:
123,6000(十进制)||62616964757a686964616fe78988e69d8331333366306436 077(八进制)|| 0x3ABC(十六进制)
声明:
int x =12 ;
占用字节内存:4
取值范围:-2^31--2^31-1
byte 型
常量:
不存在
声明:
byte x = -12 ;
占用字节内存:1
取值范围:-2^7--2^7-1
short 型
常量:
不存在
声明:
short x = 12;
占用字节内存:2
取值范围:-2^15--2^15-1
long 型
常量:
用后缀 L 来表示,如:108L等
声明:
long width = 12L;
占用字节内存:8
取值范围:-2^63--2^63-1