3

Apex classes can’t be static. And I also heard that 'all nested classed behave like Java static nested classes.'

In this case it should be possible to refer Inner1 from Inner2. But it fails with 'unexpected token: 'Inner1 ''

public class Outer {

    public class Inner1 {
    }

    public class Inner2 {

        public void foo() {
           Inner1 i = new Inner1();
        }

    }


}

1 Answer 1

3

Looks like you are doing some sort of syntax error .

I just compiled the below class .One thing to note is keyword Outer is reserved and hence used Outer 1 and all set to go

public class Outer1 {

public class Inner1 {
}

public class Inner2 {

    public void foo() {
       Inner1 i = new Inner1();
    }

 }
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .