会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 132465个问题
Python 全系列/第十五阶段:Python 爬虫开发/scrapy框架使用 35056楼
Python 全系列/第一阶段:Python入门/编程基本概念 35057楼
Python 全系列/第一阶段:Python入门/控制语句 35058楼
JAVA 全系列/第二阶段:JAVA 基础深化和提高/IO 流技术(旧) 35060楼
Python 全系列/第一阶段:Python入门/Python入门(动画版) 35061楼
Python 全系列/第一阶段:Python入门/Python入门(动画版) 35062楼

问题描述1.png

问题描述2.png

属性为private类型,为什么还可以取到值?

JAVA 全系列/第五阶段:JavaWeb开发/JSP技术详解(旧) 35063楼
JAVA 全系列/第三阶段:数据库编程/Oracle 数据库的使用 35064楼

为啥我这个代码运行后,指定的目录下没有Object.txt文件?

但是运行read()方法后可以读的出来

package com.bjsxt.Object2;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

public class Test {
	public static void main(String[] args) {
		write();
		//read();
	}
	
	//写对象的方法
	public static void write() {

		//创建对象流对象
		ObjectOutputStream oos = null;
		try {
			oos = new ObjectOutputStream(new FileOutputStream("E:\\Object.txt"));
			//写对象
			oos.writeObject(new Student("marry", 23));
			oos.writeUTF("写对象");
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally {
			//关闭
			if(oos!=null) {
				try {
					oos.close();
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}
		
	}
	
	//读对象的方法
	public static void read() {
		ObjectInputStream ois = null;
		try {
			ois = new ObjectInputStream(new FileInputStream("E:\\Object.txt"));
   System.out.println(ois.readObject());	
   System.out.println(ois.readUTF());
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally {
			 //关闭
			   if(ois!=null) {
				   try {
					ois.close();
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			   }
		}
	  
	}
}


JAVA 全系列/第二阶段:JAVA 基础深化和提高/IO 流技术(旧) 35065楼
JAVA 全系列/第一阶段:JAVA 快速入门/面向对象详解和JVM底层内存分析 35066楼

当敌方子弹击中我方坦克时,游戏界面停止了,并没有出现爆炸效果
pygametimerandom
pygame.sprite Sprite

SCREEN_WIDTH SCREEN_HEIGHT BG_COLOR pygame.TEXT_COLOR pygame.BaseItemSpritepygame.sprite.Sprite.MainGamewindow my_tank enemyTankList enemyTankCount myBulletList enemyBulletList explodeList pygame.display.MainGame.window pygame.display.SCREEN_WIDTHSCREEN_HEIGHTMainGame.my_tank Tank.pygame.display.time.MainGame.window.BG_COLOR.MainGame.window..MainGame.enemyTankListMainGame.my_tank MainGame.my_tank.liveMainGame.my_tank.MainGame.my_tank
                MainGame.my_tank ....MainGame.my_tank MainGame.my_tank.liveMainGame.my_tank.stopMainGame.my_tank.pygame.display.top i MainGame.enemyTankCountleft random.speed random.enemy EnemyTanklefttopspeedMainGame.enemyTankList.enemyexplode MainGame.explodeListexplode.liveexplode.MainGame.explodeList.explodeenemyTank MainGame.enemyTankListenemyTank.liveenemyTank.enemyTank.enemyBullet enemyTank.enemyBulletMainGame.enemyBulletList.enemyBulletMainGame.enemyTankList.enemyTankmyBullet MainGame.myBulletListmyBullet.livemyBullet.myBullet.myBullet.MainGame.myBulletList.myBulletenemyBullet MainGame.enemyBulletListenemyBullet.liveenemyBullet.enemyBullet.enemyBullet.MainGame.enemyBulletList.enemyBulletpygame.font.font pygame.font.textSurface font.TEXT_COLORtextSurface

    eventList pygame.event.event eventListevent.type pygame.QUIT.event.type pygame.KEYDOWNMainGame.my_tank MainGame.my_tank.liveevent.key pygame.K_LEFTMainGame.my_tank.direction MainGame.my_tank.stop event.key pygame.K_RIGHTMainGame.my_tank.direction MainGame.my_tank.stop event.key pygame.K_UPMainGame.my_tank.direction MainGame.my_tank.stop event.key pygame.K_DOWNMainGame.my_tank.direction MainGame.my_tank.stop event.key pygame.K_SPACEMainGame.myBulletListmyBullet BulletMainGame.my_tankMainGame.myBulletList.myBulletevent.type pygame.KEYUPevent.key pygame.K_UP pygame.K_DOWN event.key pygame.K_LEFT event.key pygame.K_RIGHTMainGame.my_tank MainGame.my_tank.liveMainGame.my_tank.stop TankBaseItem.images pygame.image.pygame.image.pygame.image.pygame.image..direction .image .images.direction.rect .image..rect.left .rect.top .speed .stop .live .direction .rect.left .rect.left .speed
        .direction .rect.top .rect.top .speed
        .direction .rect.top .rect.height SCREEN_HEIGHT.rect.top .speed
        .direction .rect.left .rect.height SCREEN_WIDTH.rect.left .speed

    Bullet.image .images.directionMainGame.window..image.rectMyTankTankEnemyTankTankEnemyTank..images pygame.image.pygame.image.pygame.image.pygame.image..direction ..image .images.direction.rect .image..rect.left .rect.top .speed .flag .step num random.num num num num .step .direction ..step ..step num random.num BulletBulletBaseItem.image pygame.image..direction .direction
        .rect .image..direction .rect.left .rect.left .rect.width.rect.width.rect.top .rect.top .rect.height
        .direction .rect.left .rect.left .rect.width.rect.width.rect.top .rect.top .rect.height
        .direction .rect.left .rect.left .rect.width.rect.width.rect.top .rect.top .rect.width.rect.width.direction .rect.left .rect.left .rect.width
            .rect.top .rect.top .rect.width.rect.width.speed .live .direction .rect.top .rect.top .speed
            .live .direction .rect.left .rect.width SCREEN_WIDTH.rect.left .speed
            .live .direction .rect.top .rect.height SCREEN_HEIGHT.rect.top .speed
            .live .direction .rect.left .rect.left .speed
            .live MainGame.window..image.rectenemyTank MainGame.enemyTankListpygame.sprite.enemyTankenemyTank.live .live explode ExplodeenemyTankMainGame.explodeList.explodeMainGame.my_tank MainGame.my_tank.livepygame.sprite.MainGame.my_tankexplode ExplodeMainGame.my_tankMainGame.explodeList.explode.live MainGame.my_tank.live WallExplode.rect .rect
        .images pygame.image.pygame.image.pygame.image.pygame.image.pygame.image..step .image .images.step.live .step .images.image .images.step.step MainGame.window..image.rect.live .step Music__name__ MainGame.

11.jpg

22.jpg

Python 全系列/第二阶段:Python 深入与提高/游戏开发-坦克大战 35067楼
JAVA 全系列/第九阶段:权限控制与安全认证/Shiro(旧) 35068楼
JAVA 全系列/第五阶段:JavaWeb开发/Servlet技术详解(旧) 35070楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637