Hi,The problem is you have the main method in your two classes.
Get rid of  this code "public static void main(String[] args) {   }" in your
second class and you should be OK.

2009/7/11 Sonu Mittal <[email protected]>

>
> I have 2 files namely food.java and foodmain.java both files' code is
> given below.
>
> FOODMAIN.java
>
> package foodpackagefruitpackage;
> public class foodmain {
>     public foodmain(){}
> public static void main(String []args){
>     int price;
>     food d=new food();
>     d.food("apple");
>     d.food(10);
>     price=d.getprice();
>     System.out.println(price);
>     //System.out.println(d.getprice());
>     }
> }
>
> FOOD.java
>
> package foodpackagefruitpackage;
> public class food {
>    public food(){}
>    public String name;
>    public int price;
>    public void food(String nm){
>        this.name=nm;    }
>    public void food(int pr){
>        price=pr;    }
>    public String getname(){
>        return name;    }
>    public int getprice(){
>        return price;    }
>    public static void main(String[] args) {
>    }
> }
>
> I am suing netbeans. Netbeans neither show any error nor show output.
> tell me whats the error.
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to