Monday, December 12, 2022

[FIXED] How do you print the value of an int inside square brackets in Java?

Issue

The output of my program needs to be the value of an int printed inside square brackets but i can't work out how to type this so that it will compile!?


Solution

If I am understanding the question.

Say you have an int

int number = 0;

and you have a print statement.

System.out.println("This is the number : [" + number + "]");

That is how you do it.



Answered By - DejaVuSansMono
Answer Checked By - Katrina (PHPFixing Volunteer)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.