Page 1 of 1
Assist with issue
Posted: Mon Oct 12, 2020 4:28 pm
by johannes77.vdm@gmail.com
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.
Re: Assist with issue
Posted: Fri Dec 11, 2020 6:09 pm
by leonardo.a.tosetto@gmail.com
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");
}
}
}
Re: Assist with issue
Posted: Sat Dec 12, 2020 12:59 am
by leonardo.a.tosetto@gmail.com
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");
}
}
}