class statementB{ int x1; double x1; statementB(int x1, double x1){ this.x1 = x1; this.x1 = x1; } boolean methodB(){ return (x1 == x1); } } public class Open1B{ statementB agentA = new statementB(7, 7.0); statementB agentB = new statementB(7, 7.0); boolean example1 = agentA.methodB(); } // Program Output: //jpdesilva@Juans-MacBook-Pro cse11-pa3-starter-main % ./run Open1b.java //Open1B.java:3: error: variable x1 is already defined in class statementB // double x1; // ^ //Open1B.java:4: error: variable x1 is already defined in constructor statementB // statementB(int x1, double x1){ // ^ //Open1B.java:5: error: incompatible types: possible lossy conversion from double to int // this.x1 = x1; // ^ //Open1B.java:6: error: incompatible types: possible lossy conversion from double to int // this.x1 = x1; // ^ //4 errors //jpdesilva@Juans-MacBook-Pro cse11-pa3-starter-main %
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter