package android.serialport.sample;import android.serialport.sample.VMC_Comm_Package_Class;import java.nio.Buffer;
/**
 * Created by kdx on 2018/1/30.
 */public class VMC_Comm_Tx_Class {//    public class LineUp{
//        byte[] Buffer;/*发送数据缓冲区*/
//        byte Index;/*发送数据计数器*/
//    }
         byte[] Buffer;
         byte Index;
    public  void VMC_Comm_Tx_Class(){
         byte inc,data=0;
         this.RepeatNum = 0;
         this.WaitResponse =0;
         this.WaitResponseTimeout =0;
          byte[] Buffer = new byte[1024];
          Index =0;
//        lineUps[0].Buffer = new byte[1024];
//
//        lineUps[0].Index = 0;
//        lineUps[1].Buffer = new byte[1024];
//        lineUps[1].Index = 0;
//        for(int i=0;i<1024;i++) {
//            lineUps[0].Buffer[i] =0x33;
//            lineUps[1].Buffer[i] =0x33;
//        }
    }
    public void VMC_Comm_Package_Pack(byte inc,byte data){        Buffer[inc] = data;
             //lineUps[0].Buffer[inc] = data;
    }
    public byte[] VMC_Comm_Package_Data(){
        return  Buffer;
    }
    /*
    **设置消息包的长度
    */
    public void VMC_Comm_Package_set_Index(byte num,byte len){
         switch (num){
             case 0:
             {
                 Index = len;
             }break;
             case 1:
             {
                 Index = len;
             }
         }
    }
    /*
    **获取消息包的长度
    */
    public byte VMC_Comm_Package_get_Index(byte num){
        byte i =0;
        switch (num){
            case 0:
            {
                 //i = lineUps[0].Index;
                i=Index;
            }
            break;
            case 1:{
                 //i= lineUps[1].Index ;
                i=Index;
            }
            break;
        }
        return i;
    }    byte RepeatNum;/*重发的次数*/
    byte WaitResponse;/* 等待PC机应答标志*/
    int WaitResponseTimeout;/*等待应答的超时时间*/
    //LineUp[] lineUps = new LineUp[2];
}
代码如上,小弟刚开始搞java 学的不太扎实,找了一天没找到哪错了,求大神
编译成功,但是运行时闪退 logcat 提示如下信息。Caused by: java.lang.NullPointerException
                                                                             at android.serialport.sample.VMC_Comm_Tx_Class.VMC_Comm_Package_Pack(VMC_Comm_Tx_Class.java:41)
                                                                             at android.serialport.sample.MainMenu.onCreate(MainMenu.java:52)
Buffer[inc] = data  这句话就是第41行,不知道这句话有什么错吗?谢谢。