Results 1 to 4 of 4

Thread: what wrong

  1. #1
    pro85 is offline Member
    Join Date
    Apr 2008
    Posts
    16
    Rep Power
    0

    Default what wrong

    public Balloon(int initialDiameter, int initialX, int initialY) {
    diameter = initialDiameter;
    xCoord = initialX;
    yCoord = initialY;
    }


    error occur is Balloon.java : 1 : ' class' or ' interface ' expected
    public Balloon(int initialDiameter, int initialX, int initialY) {

    when i change
    public balloon(int initialDiameter, int initialX, int initialY) {

    the error still the same >>>Balloon.java : 1 : ' class' or ' interface ' expected

  2. #2
    mtyoung is offline Senior Member
    Join Date
    Dec 2008
    Location
    Hong Kong
    Posts
    473
    Rep Power
    6

    Default

    a class file should has following structure
    Java Code:
    package xxx // if exist
    
    import ... // if needed
    
    public class XXXNAME{
         public XXXNAME(){} // default constructor if needed
    
         other methods
         variables
    }

  3. #3
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    8

    Default Methods & Constructors

    A class needs to contain methods (the methods do all the work). A method that is called when the class is instantiated is called a constructor.

    Providing Constructors for Your Classes (The Java™ Tutorials > Learning the Java Language > Classes and Objects)

    Defining Methods (The Java™ Tutorials > Learning the Java Language > Classes and Objects)

    Luck,
    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

  4. #4
    satya kishore is offline Member
    Join Date
    Aug 2007
    Posts
    4
    Rep Power
    0

    Default

    [QUOTE=pro85;55264]
    you havn't declared any class or interface even you havn't declared the int variables xCoord,yCoord

    public class Balloon{
    int xCoord=0;
    int yCoord=0;
    public Balloon(int initialDiameter, int initialX, int initialY) {
    diameter = initialDiameter;
    xCoord = initialX;
    yCoord = initialY;
    System.out.println(" values"+xCoord);
    System.out.println(" values"+yCoord);
    }


    }

Similar Threads

  1. What did i do wrong
    By jpnym15 in forum New To Java
    Replies: 8
    Last Post: 11-17-2008, 11:07 AM
  2. what's wrong in here!!!
    By Annatar in forum New To Java
    Replies: 8
    Last Post: 11-14-2008, 03:55 AM
  3. So, what am I doing wrong?
    By Charles_Smith in forum New To Java
    Replies: 0
    Last Post: 10-29-2008, 03:50 PM
  4. Can someone tell me what I did wrong??
    By booter4429 in forum New To Java
    Replies: 7
    Last Post: 08-13-2008, 09:35 PM
  5. I am Doing Something Wrong But Don't Know What?
    By BHCluster in forum New To Java
    Replies: 3
    Last Post: 04-16-2008, 02:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •