Assist with issue

Do you have a compilation error or a difficult problem to solve? Ask for help here
Post Reply
johannes77.vdm@gmail.com
Posts: 1
Joined: Mon Sep 28, 2020 4:09 pm

Assist with issue

Post by johannes77.vdm@gmail.com » Mon Oct 12, 2020 4:28 pm

Good Day

I created a class as shown in link below
https://www.browxy.com#USER_321800

I get error when running the program. I have copied the code from a demonstration and are correct as in demo.

Please assist.

leonardo.a.tosetto@gmail.com
Posts: 5
Joined: Tue Nov 12, 2019 1:16 am

Re: Assist with issue

Post by leonardo.a.tosetto@gmail.com » Fri Dec 11, 2020 6:09 pm

Hi!
try with this solution :

Code: Select all

package domain; //add packge domain 
// and right click over project select edit project properties and set main class option to : domain.HelloWorld
public class HelloWorld {

    public static void main(String[] args) {
        
        // class should be lowercase
        class Number {
            
            
            int number;
            public boolean isPositive() {
                
                if (number>0) {
                    
                    return true;
                }else {
                    
                    return false;
                }
         
            }
        } // close Number class   
            Number myNumber = new Number();
            
            myNumber.number = 7;
            
            if (myNumber.isPositive()) {
                
                System.out.println(myNumber.number +"is positive");
            }else {
                
                System.out.println(myNumber.number + "is not positive");
            }
    }

}


leonardo.a.tosetto@gmail.com
Posts: 5
Joined: Tue Nov 12, 2019 1:16 am

Re: Assist with issue

Post by leonardo.a.tosetto@gmail.com » Sat Dec 12, 2020 12:59 am

Hi!
Try with this solution

Code: Select all

package domain; //add packge domain 
// and right over project select edit project properties and set main class option to : domain.HelloWorld
public class HelloWorld {

    public static void main(String[] args) {
        
        // Class should be lowercase
        class Number {
            
            
            int number;
            public boolean isPositive() {
                
                if (number>0) {
                    
                    return true;
                }else {
                    
                    return false;
                }
         
            }
        } // close Number class   
            Number myNumber = new Number();
            
            myNumber.number = 7;
            
            if (myNumber.isPositive()) {
                
                System.out.println(myNumber.number +"is positive");
            }else {
                
                System.out.println(myNumber.number + "is not positive");
            }
    }

}


Post Reply