• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Help with compiler error

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello. I am having problems getting my program to compile. I am getting 1 error message: 'class' or 'interface' expected
class Cube1{}{
Could anyone please offer some suggestions. Thanks.
Troy
Here is my code:
// This class name is Cube1
public class Assignment6_5 {
public static void main(String[] args) {
Cube1 cube = new Cube1();
double newWidth = (1.0);
double newHeight = (1.0);
double newLength = (1.0);
String newColor = ("white");
System.out.println(cube.toString());
}
}
class Cube1{}{

private double width = 1.0;

private double height = 1.0;

private double length = 1.0;

private static String color = "white";
public Cube1(){}{
}

public Cube1(String newColor){}{
this.color = new color;
}

public Cube1(double newWidth, double newHeight, double newLength){}
{
this.Width = newwidth;
this.Height = newHeight;
this.Length = newLength;
}
public Cube1(double newWidth, double newHeight, double newLength, String newColor){}
{
this.Width = newWidth;
this.Height = newHeight;
this.Length = newLength:
this.Color = newColor;
}
public double getVolume(){}{
return Volume;
}
public double getWidth(){}{
return Width;
}
public double getHeight(){}{
return Height;
}
public double getLength(){}{
return Length;
}
public String getColor(){}{
return Color;

}
}
 
Ranch Hand
Posts: 688
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
why do you have class Cude1{} in this way?
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In many places in this code, you have got a set of empty "{}" braces. In every case, it's incorrect syntax. Not sure what you're going for with that -- can you explain it to us?
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry, i just want to ask why some classes are
the type" public abc(){}{} "??
"{}" emerges two times?
ps.sorry my english is poor,
 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your code in code tags with errors highlighted:



Your code with syntax corrected and formatted:
Notice the extra curly braces are gone, and how much more readable it looks.

 
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
More errors. this.Width instead of this.width, this.Height instead of this.height.....and many more.
Hopefully this will compile. But.. the purpose?

------------------
Sainudheen
 
Troy Johnson
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks everyone for you help. Sorry, I am new to Java and still trying to learn the concepts. Again, I really appreciate everyone's help. Thanks again. This has really been a great help.
Troy
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic