public static void main(String[] args) { Map<String, String> map = new HashMap<String, String>(); System.out.println("map为空:" + map.isEmpty()); //加入元素 ...
分类:
其他好文 时间:
2020-07-29 15:28:03
阅读次数:
195
8)数组的排序 int [ ] arr = {23,64,2,37,43,67,1}; Arrays.sort(arr); for (int i = 0; i<arr.length; i++){ System.out.println(arr[i]); } 方法:(函数、过程) 1)方法用于封装一段特 ...
分类:
编程语言 时间:
2020-07-28 22:45:54
阅读次数:
69
方法的可变参数: 方法中有无参方法,有带参方法,都多个参数的方法;代码如下: public class Dome { /* 方法无参和带参 */ public static void method() { System.out.println("我是一个无参的方法"); } public stati ...
分类:
其他好文 时间:
2020-07-28 22:21:42
阅读次数:
100
Java中Method类和invoke方法详解 在说Method和invoke的使用之前我们来看一个小例子, 如果看懂了那就ok了 public class MethodInvoke { class Animal { public void print() { System.out.println( ...
分类:
编程语言 时间:
2020-07-28 17:01:19
阅读次数:
75
示例如下: boolean ? Object o1 : Object o2 编译时就必须保证o1和o2为同一类型变量 Object o = true ? new Integer(1) : new Double(2.0); System.out.println(o); //1.0 先把后边两个对象转换 ...
分类:
其他好文 时间:
2020-07-26 19:13:48
阅读次数:
71
学习内容: 一、多态 1.定义:同一变量,同一方法执行出不同结果。 示例代码: class Animal{//创建父类 void move() { }}class Dog extends Animal{//子类1 void move() { System.out.println("狗的移动方式是跑步 ...
分类:
其他好文 时间:
2020-07-26 15:50:58
阅读次数:
62
1. math package com.qf.demo02; public class Test2Math { public static void main(String[] args) { System.out.println(Math.PI);//圆周率,3.141592653589793 S ...
分类:
编程语言 时间:
2020-07-26 01:31:27
阅读次数:
68
1.继承 Thread类,并重写run()方法: public class Thread001 extends Thread{ @Override public void run() { System.out.println(Thread.currentThread().getName()+"我是子 ...
分类:
编程语言 时间:
2020-07-26 00:11:57
阅读次数:
69
1.if 语句 object Test { def main(args: Array[String]) { var x = 10; if( x < 20 ){ println("x < 20"); } } } 结果 x < 20 2.if...else 语句 object Test { def ma ...
分类:
其他好文 时间:
2020-07-25 23:59:03
阅读次数:
120
注意,default语句不是必须放在case语句的结尾处出现。 例子程序: int i=9; switch (i) { default: System.out.println("default"); case 0: System.out.println("zero"); break; case 1: ...
分类:
其他好文 时间:
2020-07-25 23:38:15
阅读次数:
136