byte[] wux="obtain this string' code".getBytes(); for(int i=0;i<wux.length;i++){ System.out.println(wux[i]); }
不转成int也可以,直接打出来就是了。
public class TestChar { public static void main(String[] args) { String t = "this is a test for ASCII code!"; for(int i=0;i<t.length();i++) { int ascii=t.charAt(i); System.out.println(t.charAt(i)+"<--->"+ascii); } }}
for(int i=0;i<wux.length;i++){
System.out.println(wux[i]);
}
{
public static void main(String[] args)
{
String t = "this is a test for ASCII code!";
for(int i=0;i<t.length();i++)
{
int ascii=t.charAt(i);
System.out.println(t.charAt(i)+"<--->"+ascii);
}
}}
t<--->116
h<--->104
i<--->105
s<--->115
<--->32
i<--->105
s<--->115
<--->32
a<--->97
<--->32
t<--->116
e<--->101
s<--->115
t<--->116
<--->32
f<--->102
o<--->111
r<--->114
<--->32
A<--->65
S<--->83
C<--->67
I<--->73
I<--->73
<--->32
c<--->99
o<--->111
d<--->100
e<--->101
!<--->33
楼主不要被误导了。