Created
July 7, 2016 03:43
-
-
Save griajobag/bfe547b832c63991329e7aad523ca0dc to your computer and use it in GitHub Desktop.
null pointer example 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* To change this license header, choose License Headers in Project Properties. | |
* To change this template file, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
package error; | |
/** | |
* | |
* @author putuguna | |
*/ | |
public class NullPointer { | |
public static void main(String[] args) { | |
String kalimat = "Saya akan belajar java"; | |
String kalimatTest=null; | |
/** | |
* kita anggap saja jika kita tidak tau | |
* kalau kalimatTest itu nilainya null | |
*/ | |
String [] kalimatSplit = kalimatTest.split(""); | |
for (int i = 0; i < kalimatSplit.length; i++) { | |
System.out.println("Kalimatnya : " + kalimatSplit[i]); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment