dimanche 31 juillet 2016

how integer can return null value or throw NullPointerException [duplicate]

This question already has an answer here:

Why following snippet throw NullPointerException

package com.practice.test;

public class Test {

    int getValue(){
        return (true?null:0);
    }
    public static void main(String[] args) {
        Test t = new Test();
        t.getValue();
    }

}

Aucun commentaire:

Enregistrer un commentaire