开发者

How do i import AWT? [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 9 years ago开发者_如何学Python.

Im teaching myself java and the book i'm looking at just got around to explaining AWT.

here is my source code:

java.awt.*

class obj
{
    public static void main (String[]arg)
    {
        Point blank; 
        blank = new Point (3,4) ; 
        int x = blank.x ;
        System.out.prinln (x) ; 
    }
}

here is the error i get while trying to compile it:

obj.java:1: 'class' or 'interface' expected
java.awt.*
^
1 error

What did i do wrong? / whats going wrong here?


You're missing import in the beginning:

import java.awt.*;


You need to use a import statement at the top like:

import java.awt.*;

You'll find this Sun tutorial useful: Using Package Members


Don't concentrate on the fact that you are learning "awt". Remember your Java basics first and apply that knowledge to solve your problem.

the "awt" package is no different then any other package, you need an "import" statement.

Look at any other example in the book or forums to see how they are coded.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜