On Jul 11, 5:25 pm, Sonu Mittal <[email protected]> wrote:
> 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);
Besides what Freddy has pointed out. Usage of a constructor. Like:
 food apple=new food("Apple");
 String name=apple.getName();
 System.out.println(name);
>      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