SHARE
TWEET

Split

a guest Jan 11th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class Split
  2. {
  3.     public static void main(String[] args)
  4.     {
  5.         String kalimat = "Belajar java";
  6.         String nomor = "085-1234-5678";
  7.        
  8.         String[] kata = kalimat.split("\\s");
  9.         String[] bagian = nomor.split("-");
  10.        
  11.         String bagian1 = bagian[0];
  12.         String bagian2 = bagian[1];
  13.         String bagian3 = bagian[2];
  14.        
  15.         for(String kal :kata)
  16.         {
  17.             System.out.println(kal);
  18.         }
  19.        
  20.         System.out.println("Nomor : " +bagian1+bagian2+bagian3);
  21.     }
  22. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top