- 博客(14)
- 收藏
- 关注
原创 Java基础之计算十进制整数的二进制格式中“1”的个数
package com.xgk.chapterone;import java.util.Scanner;public class T1_5 {//压制异常 @SuppressWarnings("all") public static void main(String[] args) { int n = 0; Scanner sc = new Scanner(System.in...
2019-12-28 22:52:35 406
原创 Java基础之猜字谜
package com.xgk.chapteronework;import java.util.Random;import java.util.Scanner;public class T1_2 { @SuppressWarnings("all") public static void main(String[] args) { Random ra = new Random();...
2019-12-28 17:07:48 290
原创 Java基础之基础语法之求乱序数组第K大的元素
@SuppressWarnings("all") public static void main(String[] args) { int[] arr = { 48, 36, 61, 82, 72, 11, 58, 48 }; Scanner sc = new Scanner(System.in); int k = 0; System.out.println("Enter th...
2019-12-25 15:16:35 131
原创 Java基础之oop案例之酒店与员工
厨师类public class Chief extends Bar implements Vip{ @Override void work() { // TODO Auto-generated method stub System.out.println("Food"); } @Override public void Vipwork() { // TODO Auto-...
2019-12-15 10:40:18 198
原创 Java基础之基础语法之猜数字游戏
public static void main(String[] args) { Random random = new Random(); int r = random.nextInt(100); Scanner sc = new Scanner(System.in); System.out.println("Start -1,quit -2"); int nextInt ...
2019-12-14 14:37:59 133
原创 Java基础之基础语法之随机点名
##随机抽取五个人及其所在数组的位置,并且五个人没有重复###方法一: public static void main(String[] args) { String[] names = { "自定义名字池" }; Random random = new Random(); int flag[] = new int[names.length]; for (int i = 0; ...
2019-12-14 13:55:35 217
原创 Java基础之集合与泛型之map排序
public class Student implements Comparable<Entry>{String name;int age;public Student(String name, int age) { super(); this.name = name; this.age = age;}public Student() { super(); // T...
2019-12-14 11:37:58 124
原创 Java基础之IO流之写入文件
给定字符串,统计单词个数并且写入文件public static void main(String[] args) throws Exception { String s = "If you want to change your fate I think you must come to the iss isscollege to learn java"; //以空格分割 Strin...
2019-12-10 11:20:55 143
原创 Java基础之I/O之四种方法复制文件
1.基本流,单个字符复制,计算耗时2.基本流,多个字符复制,计算耗时3.高效流,单个字符复制,计算耗时4.高效流,多个字符复制,计算耗时public static void main(String[] args) throws Exception{ File source = new File("P:\\java\\eclipse-jee-2019-03-R-win32-x86_64.z...
2019-12-09 13:38:59 88
原创 复制目录以及其子目录和子文件
public static void main(String[] args) throws Exception { File file = new File("F:\\a"); File file2 = new File("F:\\Test"); judgeFile(file, file2); } public static void judgeFile(File targe...
2019-12-08 22:58:54 162
原创 Java基础之I/O流之单个文件复制
public static void main(String[] args) throws Exception { //创建File对象链接到被复制的文件 File file = new File("C:\\Users\\Administrator\\Desktop\\CopyJpg.jpg"); //创建File对象链接到复制文件,最好是制定文件格式,即加上后缀名 File file2 ...
2019-12-06 17:13:06 97
原创 Java基础之I/O流之删除目录
删除目录及其子目录和子文件1.利用递归列出目录的所有子目录和子文件,删除2.删除自身public class ReallyDeleteTest { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("请输入目标文件夹:"); Strin...
2019-12-05 14:54:35 90
原创 Java案例归纳之递归之记一次逻辑错误
计算1+…+n的和public class Digui { int sum=0;public static void main(String[] args) { System.out.println(new Digui().digui(2));} int digui(int n) { if(n==1) { return sum=1; } if(n>1) { sum...
2019-12-05 13:10:31 117
原创 Java案例归纳之基础语法之九九乘法表
public static void main(String[] args) { int sum=0; for (int i = 1; i <=9; i++) { for (int j = 1; j <=i; j++) { sum=i*j; System.out.print(j+"x"+i+"="+sum+" "+'\t'); } System.out.pr...
2019-12-04 11:30:18 103
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人