title: Assigning value to an array of other class by creating an object
body: <pre><code>import java.util.Scanner;
  
  public class product
  {
  int productId[];
  String productName,productType[];
  float productPrice[];
  
  public static void main(String...args)
  {
      shop ob=new shop();
      ob.startshop();
  }
  }
  
  class shop
  {   
  product obj;
  
  void startshop()
  {
      obj=new product();
      obj.productId()={1001,1002,1003,1004,1005,1006,1007,1008,1009,1010};
      obj.productName={"Cadbury","Parker Vector","Nescafe","kissan                   jam","Herbal oil","Garnier man's","Lays chips","Bourn bourn biscuits","Bournvita","Pepse"};
          obj.productType={"Chocolate","Stationary","Coffee","Jam","Oil","Face wash","chips","Biscuits","Health Supplement","Cold Drink"}
          obj.productPrice={20,150,80,65,30,79,10,20,140,24};
          Scanner oj=new Scanner(System.in);
          System.out.println(obj.productName);
          boolean c=true;
          while(c==true)
          {
              System.out.println("Please press\n1 for view all products\n2 for         view product detail\n3 to exit shop");
              int ch=oj.nextInt();
              switch(ch)
              {
                  case 1:viewAllProducts();
                      break;
                  case 2:System.out.println("Enter product id to search      starting from 1001 to 1010");
                      int i=oj.nextInt();
                      viewProductDetail(i);
                      break;
                      case 3:System.out.println("You are out of shop :)");
                      c=false;
                      break;
              }
          }
      }
      void viewAllProducts()
      {   System.out.println("ID\t\tNAME\t\tTYPE\t\tPRICE");
          for(int i=0;i&lt;10;i++)
          {
              System.out.println(obj.prductId[i]+"\t\t"+obj.productName[i]+"\t\t+"+obj.product    Type[i]+"\t\t"+obj.productPrice[i]);
          }
      }
      void viewProductDetail(int id)
      {
          int k=15;
          for(int i=0;i&lt;10;i++)
          {
          if(obj.productId[i]==id)
          k=i;
          }
          if(k&lt;10)
          {
              System.out.println("Product id "+obj.productId[k]);
              System.out.println("Product name "+obj.productName[k]);
              System.out.println("Product type "+obj.productType[k]);
              System.out.println("Product price "obj.productPrice[k]);
          }
      }
  }       
  </code></pre>
  
  <p>In this code due to following lines the code is giving error</p>
  
  <blockquote>
    <p>obj.productId()={1001,1002,1003,1004,1005,1006,1007,1008,1009,1010};
          obj.productName={"Cadbury","Parker Vector","Nescafe","kissan
    jam","Herbal oil","Garnier man's","Lays chips","Bourn bourn
    biscuits","Bournvita","Pepse"};
          obj.productType={"Chocolate","Stationary","Coffee","Jam","Oil","Face
    wash","chips","Biscuits","Health Supplement","Cold Drink"};
          obj.productPrice={20,150,80,65,30,79,10,20,140,24};</p>
  </blockquote>
  
  <p>Please tell me if i am using a wrong syntax to initialize the instance variable of other class. </p>