DAY02java代码

我们都是神枪手

import java.awt.*;
import java.awt.image.*;
public class Gogo{
	public static void main(String[] args)throws Exception{
		/*
			bot.mouseMove() 移动鼠标
			bot.mousePress() 点击鼠标
			bot.mouseRelease() 松开鼠标

			bot.createScreenCapture() 创建屏幕截图~
		*/
		Thread.sleep(5000);
		Robot bot = new Robot();//创建一个"机器人"
		BufferedImage img = bot.createScreenCapture(new Rectangle(1024,768));
		for(int x = 100;x<img.getWidth();x++){
			for(int y = 100;y<img.getHeight()-100;y++){

				/*
					58 28 183
					58=>32 + 16 + 8 + 2 = 00111010
					28=>16+8+4 = 00011100
					183=>128+32+16+4+2+1=10110111

					Alpha    RED      GREEN    BLUE
					00000000 00111010 00011100 10110111
				*/

				int color = img.getRGB(x,y);
				int r = color >> 16 & 255;
				int g = color >> 8 & 255;
				int b = color & 255;
				if(r>220 && (g + b < 80)){
					bot.mouseMove(x+31,y+7);
					bot.mousePress(16);
					bot.delay((int)(Math.random()*100));
					bot.mouseRelease(16);

					x+=80;
					y+=80;
				}
			}
		}
	}
}

HelloWorld

//JDK5.0静态导入
import static java.lang.System.*;

public class HelloWorld{
	static public void main(String[] args){
		爷爷说:out.println(-5 % 2);
	};      //-1
};

TestChar

public class TestChar{
	public static void main(String[] args){
		char data1 = 20013;//\u4e2d
		char data2 = 22269;
		char data3 = 26446;
		char data4 = '白';
		System.out.println(data1);
		System.out.println(data2);
		System.out.println(data3);
	}
}

TestDouble

public class TestDouble{
	public static void main(String[] args){
		System.out.println(2.0 - 1.1);

		double sum = 0D;
		for(int i = 0;i<10;i++){
			sum += 0.1;
			System.out.println(sum);
		}
	}
		/*
		0.8999999999999999
		0.1
		0.2
		0.30000000000000004
		0.4
		0.5
		0.6
		0.7
		0.7999999999999999
		0.8999999999999999
		0.9999999999999999*/

TestInt

public class TestInt{
	public static void main(String[] args){
		//中创             十进制  八进制 十六进制  二进制
		System.out.println(12 +    012 + 0x12 +    0b1011);
		//51
	}
}

TestLong

public class TestLong{
	public static void main(String[] args){
		//System.out.println(24 + 2L);
		//long类型定义为什么要加L

		//一年有多少毫秒数
		System.out.println(365 *24*60*60*1000);
		System.out.println(365L*24*60*60*1000);
	}    //1471228928
	     //31536000000
}

TestOperator

public class TestOperator{
	public static void main(String[] args){
		int x = 5;
		int y = 7;
		System.out.println(x++ + ++y + y-- - y++);

		System.out.println(5 + 8 + 8 - 7);//x=6 y=8
		System.out.println(x);
		System.out.println(y);

		/*
		int num = 3;
		num += 5.5;//num = (int)(num + 5.5);

		System.out.println(1 + 3 + "1" + 5);

		System.out.println(5 / 2 * 2);

		//瓷砖14块一箱子 183块
		//这是以后的分页公式 = (总记录数+每页显示多少条-1) / 每页显示多少条 = 总共页数
		System.out.println((183+13)/14);

		System.out.println(5 % 2);//1
		System.out.println(5 % -2);//1
		System.out.println(-5 % 2);//-1
		System.out.println(-5 % -2);//-1
		*/
	}
}

猜你喜欢

转载自blog.csdn.net/qq_41895253/article/details/81946405