How to print a Vec?

let v2 = vec![1; 10]; println!(“{:?}”, v2); {} is for strings and other values which can be displayed directly to the user. There’s no single way to show a vector to a user. The {:?} formatter can be used to debug it, and it will look like: [1, 1, 1, 1, 1, 1, 1, 1, … Read more

How can I support println in a class?

You can print any Object using System.out.println(Object). This overloaded version of println will print out toString representation of your object. If you want to customize what will be printed out, you must override the Object#toString() method, for example: public class A { private String foo; @Override public String toString() { // When you print out … Read more