01.代码如下: package TIANPAN; /** * 此处为文档注释 * * @author 田攀 微信382477247 */ public class TestDemo { public static void main(String args[]) { for (int x = 0; x < args.length; x++) { // 循环输出参数 System.out.println(ar
01.代码如下: package TIANPAN; class MyMath { // 数学操作类,类中没有属性 public static int add(int x, int y) { // 只是一个加法操作 return x + y; } } /** * 此处为文档注释 * * @author 田攀 微信382477247 */ public class
01.代码如下: package TIANPAN; /** * 此处为文档注释 * * @author 田攀 微信382477247 */ public class TestDemo { public static void main(String args[]) { String str = "helloworld"; // 定义字符串 System.out.println(str.length())
01.代码如下: package TIANPAN; /** * 此处为文档注释 * * @author 田攀 微信382477247 */ public class TestDemo { public static void main(String args[]) { String str = "(*(*Hello(*(*"; // 定义字符串 System.out.println(str.toUppe
01.代码如下: package TIANPAN; /** * 此处为文档注释 * * @author 田攀 微信382477247 */ public class TestDemo { public static void main(String args[]) { String str = "hello yootk"; // 定义字符串 String result[] = str.split
01.代码如下: package TIANPAN; /** * 此处为文档注释 * * @author 田攀 微信382477247 */ public class TestDemo { public static void main(String args[]) { String str = "helloworld"; // 字符串对象 if (str.contains("world&qu
01.代码如下: package TIANPAN; /** * 此处为文档注释 * * @author 田攀 微信382477247 */ public class TestDemo { public static void main(String[] args) { int numA = 9; // 定义整型变量 int numB = 11;
01.代码如下: package TIANPAN; /** * 此处为文档注释 * * @author 田攀 微信382477247 */ public class TestDemo { public static void main(String[] args) { int x = 2; System.out.println(x << 2); // 向左移2位 } } 02.效果如下:
01.代码如下: package TIANPAN; /** * 此处为文档注释 * * @author 田攀 微信382477247 */ public class TestDemo { public static void main(String[] args) { int numA = 10; int numB = 3; System.out.println(numA % numB); } } 02.效
01.代码如下: package TIANPAN; /** * 此处为文档注释 * * @author 田攀 微信382477247 */ public class TestDemo { public static void main(String[] args) { int numA = 10; int numB = 3; System.out.println(numA % 2); System.ou
01.代码如下: package TIANPAN; /** * 此处为文档注释 * * @author 田攀 微信382477247 */ public class TestDemo { public static void main(String[] args) { long num = 2147483650L; // 该数据已经超过了int数据范围 int x = (int) num;
01.代码如下: package TIANPAN; /** * 此处为文档注释 * * @author 田攀 微信382477247 */ public class TestDemo { public static void main(String[] args) { int num = 130; // 此范围超过了byte定义 byte x = (byte) num;
01.代码如下: package TIANPAN; /** * 此处为文档注释 * * @author 田攀 微信382477247 */ public class TestDemo { public static void main(String[] args) { byte num = 100 ; // 100没有超过byte的保存范围 System.out.println(num) ;
01.代码如下 package TIANPAN; /** * 此处为文档注释 * * @author 田攀 微信382477247 */ public class TestDemo { public static void main(String[] args) { int num; // 没有默认值 num = 0; // 在使用此变
01.代码如下: package TIANPAN; /** * 此处为文档注释 * * @author 田攀 微信382477247 */ public class TestDemo { public static void main(String[] args) { // 所有的变量名称在同一块代码中只允许声明一次 int num = 10; // 10是常量,常量的默认