Skip to content

Instantly share code, notes, and snippets.

@griajobag
Created July 7, 2016 03:43
Show Gist options
  • Save griajobag/bfe547b832c63991329e7aad523ca0dc to your computer and use it in GitHub Desktop.
Save griajobag/bfe547b832c63991329e7aad523ca0dc to your computer and use it in GitHub Desktop.
null pointer example 1
/*
* 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