public class loop {
int to=10;
public static void main(String[] args) {
A a = new A();
a.i=100;
a.decide();
}
}
class A { // Type A is already defined
int i;
public void decide() {
int i=0;
System.out.println(i);
}
}
for the above program I am getting an error as (Exception in thread "main" java.lang.NoSuchMethodError: 'void A.decide()'
at loop09.main(loop09.java:8)) but in the Day 02 excercise the answer is 1. Can you explain
package loops;
public class Loop15
{
//int to = 10;
publicstaticvoidmain(String[] args)
{
Ac a=new Ac();
a.i=100;
a.decide();
}
}
class Ac
{
inti;
publicvoiddecide()
{
inti=0;
System.out.println(i);
}
}
the answer for this is 0. Try this code once