JAVA新手练习
超高校级の幸运777
这个作者很懒,什么都没留下…
展开
-
Java数组整体左右移动
//右移public class Test { public static void main(String[] args) { int[] nums = {1,2,3,4,5,6,7,8,9,10}; int m = 8; for (int a : nums){ System.out.print(a + " "); } System.out.println(); int[].原创 2022-03-08 09:41:08 · 794 阅读 · 0 评论 -
日期的格式化
import java.text.SimpleDateFormat;import java.util.Date;public class DateTest01 { public static void main(String[] args) throws Exception { Date nowTime = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss .原创 2021-08-19 14:45:53 · 108 阅读 · 0 评论 -
JAVA二分法查找代码实现
public class ArrayUtil { public static void main(String[] args) { int[] arr = {100, 200, 230, 235, 600, 1000, 2000, 9999}; int index = binarySearch(arr,100); System.out.println(index == -1 ? "该元素不存在!" : "该元素的下表为" + index); .原创 2021-08-10 17:34:42 · 47 阅读 · 0 评论 -
JAVA选择排序
public class SelectSort { public static void main(String[] args) { int[] arr = {8, 6, 2, 4, 1}; //选择排序 for (int i = 0; i < arr.length-1; i++) { int min = i; for (int j = i + 1; j < arr.length; j++).原创 2021-08-09 18:31:48 · 40 阅读 · 0 评论 -
JAVA的冒泡排序
import java.util.Arrays;public class BubbleSort { public static void main(String[] args) { int[] arr = {9, 8, 7, 6, 5, 4, 3, 2, 1, 0}; //int count = 0; for (int i = arr.length-1; i > 0 ; i--) { for (int j = 0; .原创 2021-08-09 17:06:21 · 99 阅读 · 0 评论