-2

When I execute the below code:

map.forEach((key, value) -> System.out.println(key + ":" + value));

I get 15234:[com.org.myprj.Dashboard@18a6be14] as sysout.

How to I get object value in hashmap? Here object is a row inserted in arraylist.

Pshemo
  • 122,468
  • 25
  • 185
  • 269
Aziz
  • 23
  • 6
  • Take a look at duplicate question (linked at top of this page - you may need to refresh it to see it). In short, override `public String toString(){..}` method inside `Dashboard` class to generate string which you want to see while printing `Dashboard` instance in sysout. – Pshemo Apr 30 '20 at 11:13

1 Answers1

1

implement overridden toString method in object

example

class Dashboard{   
    private double re, im; 

    public Dashboard(double re, double im) { 
        this.re = re; 
        this.im = im; 
    } 

    @Override
    public String toString() { 
        return String.format(re + " + i" + im); 
    }  
} 
Pshemo
  • 122,468
  • 25
  • 185
  • 269
nikhil
  • 877
  • 3
  • 11
  • 36