MyException - 我的异常网
当前位置:我的异常网» J2ME » ~帮帮忙,改天请喝茶,该怎么处理

~帮帮忙,改天请喝茶,该怎么处理

www.MyException.Cn  网友分享于:2013-12-30  浏览:2次
~~~~帮帮忙,改天请喝茶
public   class   mainCanvas   extends   Canvas{

int   width=getWidth();
int   height=getHeight();

}

我要在非继承Canvas类中调用
width和height的值
要怎么调用
给出具体代码

------解决方案--------------------
public class mainCanvas extends Canvas{

public static int width=getWidth();
public state int height=getHeight();

}


public class otherClass extends MIDlet
{
public void startApp(){
System.out.println(mainCanvas.width);
}
public void pauseApp(){}
public void destroyApp(boolean bl){
}
}
------解决方案--------------------
//#if "ScreenSize " == "240x320 "
int width = 240;
int height = 320;
//#else
//#int width = 176;
//#int height = 208;
//#endif

用polish编译
------解决方案--------------------
class Canvas{

private int width = 1;
private int height = 2;

public int getWidth(){

return width;
}
public int getHeight(){

return height;
}




}

class mainCanvas extends Canvas{

int width=getWidth();
int height=getHeight();

}

public class Test {

public static void main(String[] args) {
mainCanvas a = new mainCanvas();

System.out.println( "width: "+a.width + " height: "+a.height);
}

}

文章评论

软件开发程序错误异常ExceptionCopyright © 2009-2015 MyException 版权所有