Q:

Why does object with a string prints as null?

Probably a noob question but why this code prints null?
public class Bug1 { 
    private String s;
    public void Bug1() {
        s = "hello";
    }
    public String toString() {
        return s;
    }
    public static void main(String[] args) {
        Bug1 x = new Bug1();
        System.out.println(x);
    }
}

A:

You have the void keyword here, making your 'constructor' a method (which is never called), so the String s is never initialised. Object references at class level will be null by default.
public void Bug1() {

to fix, change to:
public Bug1() {

Constructors don't have return types.

