strange output from ArrayList


This question already has an answer here:


You need to override toString method. The Notizblock is a custom class, the default System.out will be classname@hashcode of the object, which is what you are seeing.

once you override the toString it will print the content of the object as per your toString implementation. Here is a sample:

public String toString() {
  return "Notizblock {" +
      "text='" + text + '\'' +
      ", datum='" + datum + '\'' +

Yes. You can call the existing print method which you have defined.

System.out.println("alle notizen:");
for (Notizblock notiz :notizen ) {

The toString() is called automatically when you print (SOUT) anything. That is why overriding toString() will be a better approach then providing a custom method for doing the same job, unless you are doing some extra/special formatting of the data.

Need Your Help

How do I add a Fragment to an Activity with a programmatically created content view

android android-3.0-honeycomb android-fragments

I want to add a Fragment to an Activity that implements its layout programmatically. I looked over the Fragment documentation but there aren't many examples describing what I need. Here is the type...

How to Pass Details Model from Controller to View

c# wcf razor

I am accessing Data in Controller using a WCF Service.