2 dxt 1515 dxt_1515 于 2016.09.20 21:18 提问

安卓自定义数据类型问题,我用一个类实现了我的自定义数据类型,可是为什么初始化的时候报错呢?

初始化报错: private CNetCommand udp_command = {0, 0, {0,0,2048,24,0,0,0,0,500,1000},{"Sensor"},1,225};
想问一下是什么原因,或者能解决感激不尽!!!
自定义数据类型

public class CNetCommand{

        public short getCommand() {
            return Command;
        }
        public void setCommand(short command) {
            Command = command;
        }
        public short getCmdIdx() {
            return CmdIdx;
        }
        public void setCmdIdx(short cmdIdx) {
            CmdIdx = cmdIdx;
        }
        public CImgSize getImgSize() {
            return ImgSize;
        }
        public void setImgSize(CImgSize imgSize) {
            ImgSize = imgSize;
        }
        public char[] getSensorName() {
            return SensorName;
        }
        public void setSensorName(char[] sensorName) {
            SensorName = sensorName;
        }
        public short getCommAddr() {
            return CommAddr;
        }
        public void setCommAddr(short commAddr) {
            CommAddr = commAddr;
        }
        public short getNetAddr() {
            return NetAddr;
        }
        public void setNetAddr(short netAddr) {
            NetAddr = netAddr;
        }
        private short          Command;             // 指令
        private short          CmdIdx;           // 指令编号
        private CImgSize       ImgSize;          // 图像尺寸
        private char SensorName[]=new char[32];   // 传感器名称
        private short       CommAddr;         // 串口地址(1或2)
        private short    NetAddr;          // 网络地址(IP地址的最后一位)
    } 
public class CImgSize{

           public short getLeft() {
            return Left;
        }
        public void setLeft(short left) {
            Left = left;
        }
        public short getTop() {
            return Top;
        }
        public void setTop(short top) {
            Top = top;
        }
        public short getWidth() {
            return Width;
        }
        public void setWidth(short width) {
            Width = width;
        }
        public short getHeight() {
            return Height;
        }
        public void setHeight(short height) {
            Height = height;
        }
        public char getRowAddrMode() {
            return RowAddrMode;
        }
        public void setRowAddrMode(char rowAddrMode) {
            RowAddrMode = rowAddrMode;
        }
        public char getColAddrMode() {
            return ColAddrMode;
        }
        public void setColAddrMode(char colAddrMode) {
            ColAddrMode = colAddrMode;
        }
        public short getShutterWidth() {
            return ShutterWidth;
        }
        public void setShutterWidth(short shutterWidth) {
            ShutterWidth = shutterWidth;
        }
        public short getCheckMode() {
            return CheckMode;
        }
        public void setCheckMode(short checkMode) {
            CheckMode = checkMode;
        }
        public short getDarkThreshold() {
            return DarkThreshold;
        }
        public void setDarkThreshold(short darkThreshold) {
            DarkThreshold = darkThreshold;
        }
        public short getBrightThreshold() {
            return BrightThreshold;
        }
        public void setBrightThreshold(short brightThreshold) {
            BrightThreshold = brightThreshold;
        }
           private short      Left;            // 图像左位置
           private short     Top;             // 图像顶位置
           private short    Width;           // 图像宽度  
           private short     Height;          // 图像高度
           private char      RowAddrMode;     // 行地址
           private char      ColAddrMode;     // 列地址
           private short     ShutterWidth;    // 快门速度
           private short     CheckMode;       // 边沿检测方式(0上升沿,1下降沿)
           private short     DarkThreshold;   // 黑暗阈值  
           private short     BrightThreshold; // 明亮阈值  

    } 

2个回答

devmiao
devmiao   Ds   Rxr 2016.09.20 21:21
dxt_1515
dxt_1515 希望能解决一下,困扰好多天了!
大约一年之前 回复
oSanYeCao1234567
oSanYeCao1234567   Ds   Rxr 2016.09.20 22:18

java类可以这样初始化 ?:
private CNetCommand udp_command = {0, 0, {0,0,2048,24,0,0,0,0,500,1000},{"Sensor"},1,225};

你把一个二维数组赋值给一个自定义对象,完全对不上啊

dxt_1515
dxt_1515 已经解决,谢谢!
大约一年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片