Hi,
I am getting exception "incompatible types" while i am running the below code. Can you please let me know where i am doing wrong in the code?
Thanks in advance
Code:
-------------------
class emp_array { int id; public emp_array (int id) { this.id = id; } public void showemp() { this.id= id; System.out.println ("id "+id); } } class emp_arraydemo { public static void main(String[] args) { emp_array e[]; int n = args.length; e = new emp_array[n]; for (int i=0; i<args.length;i++) { e[i]=Integer.parseInt(args[i]); } for (emp_array x:e) { x.showemp(); } } }
Error:
---------------------
C:\Program Files\Java\jdk1.6.0_02\bin>javac emp_array_dynamically.java
emp_array_dynamically.java:42: incompatible types
found : int
required: emp_array
e[i]=Integer.parseInt(args[i]);
^
1 error