Welcome to Dream.In.Code
Become a Java Expert!

Join 150,149 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 2,367 people online right now. Registration is fast and FREE... Join Now!




run time error

 
Reply to this topicStart new topic

run time error

rocky75111
2 Aug, 2008 - 09:45 AM
Post #1

New D.I.C Head
*

Joined: 2 Aug, 2008
Posts: 1

This is my code for an assignment that was due yesterday. I have to create a class that holds information of an item that lends it self to inventory. Then cerate an application that displays the information. This is my code. It compiles fine but upon running it , I get this error message: "exception in thread "main" java.lang.nosuch error method:". I know that I need a main method like "public static void main(Sting [] args). But no matter where I put it, i get the same error. I would appreciate any assistance. thank you.

java

public class DVD{



private String name;
private int itemNumber;
private int stockQuantity;
private double price;
public DVD(String name, int itemNumber, int stockQuantity, double price){
this.name = name;
this.itemNumber = itemNumber;
this.stockQuantity = stockQuantity;
this.price = price;

}

public String toString(){
return "DVD Title: " + this.name + "\n" +
"Item Number: " + this.itemNumber + "\n" +
"Stock Quantity: " + this.stockQuantity + "\n" +
"Price: " + this.price + "\n";
}

public String getName(){
return this.name;
}

public void setName(String name){
this.name = name;
}

public int getItemNumber(){
return this.itemNumber;
}

public void setItemNumber(int itemNumber){
this.itemNumber = itemNumber;
}

public int getStockQuantity(){
return this.stockQuantity;
}

public void setStockQuantity(int stockQuantity){
this.stockQuantity = stockQuantity;
}

public double getPrice(){
return this.price;
}

public void setPrice(double price){
this.price = price;
}
}

*edit: Please use code tags in the future, thanks! code.gif

This post has been edited by Martyr2: 2 Aug, 2008 - 09:47 AM
User is offlineProfile CardPM
+Quote Post

Martyr2
RE: Run Time Error
2 Aug, 2008 - 09:51 AM
Post #2

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 5,660



Thanked: 313 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
Ok this is your class file for DVD. Your main method is not going to be here. What you need to do is create another file called something like "DVDtest" or something and in there you would put main and create an instance of your DVD class. Here is a basic skeleton for you....

java

public class DVDtest {
public static void main(String args[]) {
DVD mydvd = new DVD();
// Do stuff with mydvd variable
}
}


Save this file as DVDtest.java and put it in the same directory as your DVD.java file. Then compile it and run it. You should see it compile and run fine, but where I have the comment you are going to use your "mydvd" variable to call methods etc.

Let us know if you have any further problems. smile.gif
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 02:32AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month