printf (Print Format) di Java

package printFormat;
public class printFormat {

public static void main(String[] args) {
int array[]={2,2,5555,1,3,5,1,1,2,8};
int jmlh=0;
System.out.printf(“%s%8s\n”, “index”, “value”);

for(int i=0;i<array.length;i++){
System.out.printf(“%4s%8s\n”, i, array[i]);
jmlh += array[i];
}
System.out.println(“\njumlah =  ” +jmlh);

}
}

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout /  Ubah )

Foto Google

You are commenting using your Google account. Logout /  Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout /  Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout /  Ubah )

Connecting to %s