「Java入門」java.util.Arrays.toString(binarySearch)の使い方

2018年3月13日

Javaコード
package com.arkgame.study;
import java.util.Arrays;

public class ChangfaTuDemo {

public static void main(String[] args) {

int cft[] = { 13, 24, 35, 47, 69, 16, 62, 76, 98 };
Arrays.sort(cft);
System.out.println(“after sort:");
System.out.println(Arrays.toString(cft));
int point = Arrays.binarySearch(cft, 47);
System.out.println(“find element 47 position:" + point);
Arrays.fill(cft, 99);
System.out.println(“fill element:");
System.out.println(Arrays.toString(cft));

}

}

結果
after sort:
[13, 16, 24, 35, 47, 62, 69, 76, 98]
find element 47 position:4
fill element:
[99, 99, 99, 99, 99, 99, 99, 99, 99]

Java

Posted by arkgame