Question: When I run my code, the user input keeps showing as 'null.' How do I fix this? public class DebugPen { private String color; private

When I run my code, the user input keeps showing as 'null.' How do I fix this?

public class DebugPen

{

private String color;

private String point;

public DebugPen()

{

color = "black";

point = "fine";

}

public DebugPen(String color, String point)

{

color = color;

point = point;

}

public String getColor()

{

return color;

}

public String getPoint()

{

return point;

}

}

import java.util.Scanner;

public class DebugFour2

{

public static void main(String[] args)

{

Scanner input = new Scanner(System.in);

String color;

String point;

DebugPen pen1;

DebugPen pen2;

System.out.print("Enter a color ink for the pen >> ");

color = input.nextLine();

System.out.print("Enter a point size - fine, medium, or thick >> ");

point = input.nextLine();

pen1 = new DebugPen();

pen2 = new DebugPen(point, color);

System.out.println("Default value pen:");

display(pen1);

System.out.println("User value pen:");

display(pen2);

}

public static void display(DebugPen p)

{

System.out.println(" The pen has ink color " + p.getColor());

System.out.println(" and a " + p.getPoint() + " point.");

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!