Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

No enclosing instance of type Foo is accessible. Must qualify the allocation with an enclosing instance of type Foo (e.g. x.new A() where x is an instance of Foo

static class SimpleCircle
Comment

No enclosing instance of type Main is accessible. Must qualify the allocation with an enclosing instance of type Main (e.g. x.new A() where x is an instance of Main).

public class TestSimpleCircle {

    class SimpleCircle {
        double radius;

        SimpleCircle(){
            radius = 1;
        }

        SimpleCircle(double newRadius){
            radius = newRadius;
        }

        double getArea() {
            return radius * radius * Math.PI;
        }

        double getPerimeter() {
            return 2 * radius * Math.PI;
        }

        void setRadius(double newRadius) {
            radius = newRadius;
        }
    }

    public static void main(String [] args) {
        SimpleCircle circle = new SimpleCircle();
        System.out.println("the area of the circle of radius "+circle.radius+" is "+circle.getArea());

        SimpleCircle circle2 = new SimpleCircle(25);
        System.out.println("the area of the circle of radius "+circle2.radius+" is "+circle2.getArea());

        SimpleCircle circle3 = new SimpleCircle(125);
        System.out.println("the area of the circle of radius "+circle3.radius+" is "+circle3.getArea());

        circle.radius = 100;
        System.out.println("The area of the circle of radius "+circle.radius+" is "+circle.getArea());
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: search and delete class files from jars 
Java :: assign a random number in a set without replacement javva 
Java :: @embeddedid 
Java :: Does JVM create object of Main class (the class with main())? 
Java :: from which android version onwards cardelevation supports? 
Java :: jbutton actionperformed 
Java :: Execute method on load alternative 
Java :: labeled break Statement Java 
Java :: how to extract word from string in java 
Java :: print zpl from java 
Java :: param vishisht seva medal 
Java :: java mcq test 
Java :: how to solve CopyBuffer from HiLo failed, no data 
Java :: polymorphism array with abstract class java 
Java :: hgjhghj 
Java :: filterreader converts a string to uppercase java 
Java :: how to add a singleton hashset in java 
Java :: zweidimensionales array erstellen java 
Java :: mergesort parallelization using spark 
Java :: Method returns value 
Java :: java reverse a word 
Java :: a to double 
Java :: dialog background dimming in android 
Java :: check if char is letter 
Java :: java to run colored lines 
Java :: how to decode a ByteArray to Bitman in adroid 
Java :: a Java-8 stream of batches, 
Java :: java regex check if group exists 
Java :: java multi threading Buzzer program 
Java :: using ..replace() in jShell/java 
ADD CONTENT
Topic
Content
Source link
Name
8+4 =