Question: In the code below, I don't know what this part, public C newC() { return new C(); } of the code is. :( Can someone
In the code below, I don't know what this part,
public C newC() { return new C(); }
of the code is. :(
Can someone explain what that part of the code does specifically?? :( :(
And additionally what does this mean?
return a < 0 ? -a : a;
I've never seen this before
---------------------------------------------------------------------------------------------------------------------------- public class Example { static int count; int c; public static class A{ public static void foo() { count++; } }
public static class B{ public void foo() { count++; } } public class C{ public void foo() { c++; } public int getC() { return c; } } public C newC() { return new C(); } public static void main(String[] args) { A.foo(); B b = new B(); b.foo(); System.out.println("B count: "+ count); Example e = new Example(); C c1= e.newC(); //using newC C c2= e.new C(); //using new c1.foo(); c2.foo(); System.out.println("e.c: " + e.c); System.out.println("c1.c: "+c1.getC()); System.out.println("c2.c: "+c2.getC()); } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
