Home » Java » java – What is wrong in the following code? How it can be fixed?-Exceptionshub

java – What is wrong in the following code? How it can be fixed?-Exceptionshub

Posted by: admin February 25, 2020 Leave a comment

Questions:

/*What is wrong in the following code?
* How it can be fixed ?
*/

public class Test{

     public static void main(String []args){
        A a = new A ();
        a.print();
     }
}
class A {
    String s;

    A (String s) {
        this.s = s;
}

 public void print () {
     System.out.print(s);
 }
}
How to&Answers: