How to create a println/print method for a custom class

前端 未结 6 1378
猫巷女王i
猫巷女王i 2020-12-01 19:23

I\'m working in Java on a project that requires me to make a few \'container\' classes, if you will. Here is a simple version of one:

public class Pair{

            


        
6条回答
  •  萌比男神i
    2020-12-01 19:48

    You can override the toString() method of your custom class and print whatever information you want.

    @Override 
    public String toString() {
    
        return .....;
      }
    

提交回复
热议问题