s.getBytes()
返回类型是一个byte数组

解决方案 »

  1.   

    byte[] sBytes = s.getBytes()
      

  2.   

    byte[] sBytes = s.getBytes();
    这个也太。
      

  3.   

    public byte[] getBytes()
    Encodes this String into a sequence of bytes using the platform's default charset, storing the result into a new byte array. 
    The behavior of this method when this string cannot be encoded in the default charset is unspecified. The CharsetEncoder class should be used when more control over the encoding process is required. 
    Returns:
    The resultant byte array
      

  4.   

    String s = new String("Hello the world!");
    byte[] bytes = s.getBytes();
      

  5.   

    实际中查看JAVA API很重要。
    找到该类,再查看其对应方法,一般看名字就大概了解该方法是干啥的
      

  6.   

    String s = new String("This is the right result!");
    byte[] bytes = s.getBytes();
    建议看<<Core Java>>一书,就不会有这样的问题了!
      

  7.   

    public class example1 {
    public static void main(String []arg){
    String s = new String("This is java application!");
    byte[] sbyte = s.getBytes();
    for (int i=0; i<sbyte.length; i++)
    System.out.println(sbyte[i]);
    System.out.println("i = "+sbyte.length);
    }}
      

  8.   

    public class Test{
    public static void main(String[] args){
    String s=new String("abcdefgh");
    byte[] b=s.getBytes();
    for (int i=0; i<b.length; i++)
    System.out.println(" "+(char)b[i]);
    }
    }
      

  9.   

    你们都有个方法getBytes()
    这个方法怎么没见你们定义出来呀。
    我也是初学JAVA者,请各位帮忙就帮到底,把这个方法说清楚些
      

  10.   

    失败,想了半天也没想出来getBytes()是哪个包里的。
    怎么办呢?我离开书什么都做不了.
      

  11.   

    楼上两位这个方法是String的方法,
    不要说你们两个的jdk没有java.util.String这个类
      

  12.   

    byte[] result = s.getBytes()
    开始的时候是这样的,时间长了能记住方法在什么包中了,熟能生巧吗!~
      

  13.   

    此分不接,对不起良心啊。
    String.getBytes()
      

  14.   

    楼主有分就给,同时希望楼主仔细看看文档和api,这样简单的问题要独立思考,自己解决才有进步!
    我要出发了,随便看看!
      

  15.   

    String.getBytes()有问题就问,别怕!
      

  16.   

    String.getBytes()
    这种分不接对不起你,去查一下API手册就知道了,跑着问,我服了你了,你要是这个水平的话,连一个编程爱好者都算不上
      

  17.   

    呵呵,我也是新手,能碰到这样的题不易,不得对不起你:
    String s = new String("i am a new guy!");
    byte[] bytes = s.getBytes();
      

  18.   

    byte[] bytes=s.getBytes();
    大家共同努力就是了!!!
    没有谁天生就是将军 的!!!谢谢你的提问!