Skip to content

Tag: tostring

toString() representation output

I have a bug in the code and believe me I’ve run debugging many times to find what’s wrong with code but cannot understand what is wrong. I have to output the contents of 2d Arraylist. For example, if I do: it outputs me the following: But when I change the fourth value, 3, to higher number, for e…

Eclipse autogenerated toString() method

As par as I know concatinate String using + sign is not a good practice when you have large number of String. But when I check on eclipse generated toString() method (Write click on source file -> Source -> Generate toString() ) it has the same. Is there any place to configure like my expected toString(…

How To Print String representation of Color in Java

I have an array of colours of size n. In my program, the number of teams is always <= n, and I need to assign each team a unique color. This is my color array: When I print information about the players in the console, I want to print what color is associated with them. When I print the color,

What is this: [Ljava.lang.Object;?

I get this when I call toString on an object I received from a function call. I know the type of the object is encoded in this string, but I don’t know how to read it. What is this type of encoding called? Answer [Ljava.lang.Object; is the name for Object[].class, the java.lang.Class representing the cl…