- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
出于某种原因,我的游戏在关卡开始时不会卡住,而菜单加载得很好!当 Boss 音乐开始时,游戏将卡住。编辑:抱歉,我发现屏幕卡住是因为 canMove 变量被设置为 false。但是,游戏仍然会随机崩溃并说找不到图像。
这是我的代码:
这是菜单(效果很好):
//Sprite sheeting
private SpriteSheet sleepSpriteSheet;
private Animation sleepAnimation;
private SpriteSheet walkSpriteSheet;
private Animation walkAnimation;
//System info
private String operatingSystem = Client.getOS();
//Game texuring
private static String IntroBackground = "res/images/level/IntroBackground.png";
private static String KnightQuestLogo = "res/images/icons/KnightQuestLogo.png";
//Menu Info
private static boolean readyForIntro = false;
private static boolean readyForPlay = false;
private static boolean showArrow = false;
private static String playButton = Button.PlayButton;
private static boolean playerSleeping = true;
private static boolean knightWalking = false;
private static float knightX = 145;
private static float knightY = 456;
private static float knightQuestLogoX = -750;
private static float knightQuestLogoY = 75;
private static boolean soundStarted = false;
public GameMenu(int State) {
}
// Render the game
@Override
public void render(GameContainer GameContainer, StateBasedGame SBG,
Graphics G) throws SlickException {
//Draw Background Image
G.drawImage(new Image(IntroBackground), 0, 0);
//Choose what animation to use
if(playerSleeping) {
sleepAnimation.draw(145, 406, 250, 250);
}
else {
walkAnimation.draw(knightX, knightY, 175, 200);
}
//Draw Floor
G.drawImage(new Image(Block.GroundTile), 0, 656);
//Draw The Logo
G.drawImage(new Image(KnightQuestLogo), knightQuestLogoX, knightQuestLogoY);
//Draw the Play Button
if(readyForPlay) {
G.drawImage(new Image(playButton), 750, 315);
if(showArrow) {
G.drawImage(new Image(Icon.Arrow), 730, 335);
}
}
//System Info
G.drawString("Game State: " + this.getID(), 10, 30);
G.drawString("X:" + Mouse.getX() + " Y:" + Mouse.getY(), 10, 50);
G.drawString("Your OS: " + operatingSystem, 10, 70);
}
// Update the game
@Override
public void update(GameContainer GameContainer, StateBasedGame SBG,
int Delta) throws SlickException {
//Start Sound (Would be started in init(), But the StopSound function will not work if done so.
if(!soundStarted) {
PlaySound.playSound("res/sounds/startup/MainMenu.wav");
soundStarted = true;
}
//When ready, slide the logo to the right
if (readyForIntro) {
if (knightQuestLogoX < 750.0) {
knightQuestLogoX += Delta * .5f;
}
}
//When ready, allow the player the press the play button
if(readyForPlay) {
if(Mouse.getX() > 755 && Mouse.getX() < 875 && Mouse.getY() > 345 && Mouse.getY() < 400) {
showArrow = true;
if(Mouse.isButtonDown(0)) {
playerSleeping = false;
knightWalking = true;
}
}
else {
showArrow = false;
}
}
//If the knight is walking in the intro, slide him off the screen
if(knightWalking) {
if(knightX < 1290) {
knightX += Delta* .5f;
}
else {
SBG.enterState(1, new FadeOutTransition(new Color(Color.black)), new FadeInTransition(new Color(Color.black)));
PlaySound.stopSound();
PlaySound.playSound("res/sounds/events/LeaveState.wav");
}
}
}
// Initialize the GameState
@Override
public void init(GameContainer GameContainer, StateBasedGame SBG)
throws SlickException {
//Start the thread for the Intro
new Thread(new MenuIntro()).start();
//Create the Sprite sheets
sleepSpriteSheet = new SpriteSheet("res/images/characters/knight/spritesheets/SleepAnimation.png", 52, 50);
sleepAnimation = new Animation(sleepSpriteSheet, 250);
walkSpriteSheet = new SpriteSheet("res/images/characters/knight/spritesheets/WalkAnimation.png", 35, 48);
walkAnimation = new Animation(walkSpriteSheet, 75);
}
// Get the ID of the GameState
@Override
public int getID() {
return 0;
}
// MenuIntro thread
static class MenuIntro implements Runnable {
@Override
public void run() {
try {
Thread.sleep(3000);
readyForIntro = true;
Thread.sleep(4000);
readyForPlay = true;
} catch (Exception e) {
e.printStackTrace();
}
}
}
这是游戏关卡(已损坏):
//Colors RGB
private static String Grey = "rgb/Grey.png";
private static String Blue = "rgb/Blue.png";
private static String Red = "rgb/Red.png";
// Level Variables
private static boolean stateStarted = false;
private static boolean startBossBattle = false;
private static boolean startedBossBattle = false;
private static boolean startedBossMusic = false;
private static boolean BothTouching = false;
// Player Variables
/* Coordinates, And Direction */
private static float PlayerX = 25;
private static float PlayerY = 470;
private static String Knight = "res/images/characters/knight/Knight.png";
private static String PlayerDirection = "right";
private static int PlayerHealth = 100;
private static boolean PlayerWalking = false;
private static boolean PlayerJumping = false;
private static boolean PlayerJumped = false;
private static float AmountPlayerJumped;
private static boolean PlayerAttacking = false;
private static boolean PlayerCanAttack = true;
private static int PlayerRegenTime = 100;
/* Sprite Sheets */
private static String PlayerLeftSword = "res/images/icons/sword/SwordLeft.png";
private static String PlayerLeftAttackSword = "res/images/icons/sword/SwordLeftAttacking.png";
private static String PlayerRightSword = "res/images/icons/sword/SwordRight.png";
private static String PlayerRightAttackSword = "res/images/icons/sword/SwordRightAttacking.png";
private static String PlayerCurrentSword = PlayerRightSword;
private static String RightKnight = "res/images/characters/knight/ResizedKnightRight.png";
private static String LeftKnight = "res/images/characters/knight/ResizedKnightLeft.png";
/* Everything Else */
private static boolean PlayerCanMove = false;
// AI Variables
/* Coordiantes and Direction */
private static float EnemyX = 1000;
private static float EnemyY = 470;
private static String EnemyKnight = "res/images/characters/knight/Knight.png";
private static String EnemyDirection = "right";
private static int EnemyHealth = 100;
private static boolean EnemyWalking = false;
private static boolean DecidedJump = false;
private static int JumpPossibility = 1;
private static boolean EnemyJumping = false;
private static boolean EnemyJumped = false;
private static float AmountEnemyJumped;
private static boolean EnemyAttacking = false;
private static boolean EnemyCanAttack = true;
private static int EnemyRegenTime = 100;
/* Sprite Sheets */
private static String EnemyLeftSword = "res/images/icons/sword/SwordLeft.png";
private static String EnemyLeftAttackSword = "res/images/icons/sword/SwordLeftAttacking.png";
private static String EnemyRightSword = "res/images/icons/sword/SwordRight.png";
private static String EnemyRightAttackSword = "/res/images/icons/sword/SwordRightAttacking.png";
private static String EnemyCurrentSword = EnemyRightSword;
private static String RightEnemy = "res/images/characters/knight/ResizedKnightRight.png";
private static String LeftEnemy = "res/images/characters/knight/ResizedKnightLeft.png";
/* Everything Else */
private static boolean EnemyTalking = false;
private static String EnemyMessage = "";
private static boolean EnemyCanMove = false;
// Mixed Variables
/* Sprite Sheets */
private static SpriteSheet WalkRightSpriteSheet;
private static Animation WalkRightAnimation;
private static SpriteSheet WalkLeftSprite;
private static Animation WalkLeftAnimation;
private static int SpriteSheetWidth = 135;
private static int SpriteSheetHeight = 188;
// System Variables
private String operatingSystem = Client.getOS();
// Constructor
public FinalBattle(int State) {
}
@Override
public void render(GameContainer GameContainer, StateBasedGame SBG,
Graphics G) throws SlickException {
//GameContainer Things
GameContainer.setShowFPS(false);
//Level
/* Draw Background */
G.drawImage(new Image("res/images/level/FinalBattle.png"), 0, 0);
/* Draw Floor */
G.drawImage(new Image(Block.GroundTile), 0, 656);
//Player
/* Draw Player */
if(PlayerWalking) {
if(PlayerDirection.equalsIgnoreCase("right")) {
if(!PlayerJumping) {
WalkRightAnimation.draw(PlayerX, PlayerY, SpriteSheetWidth, SpriteSheetHeight);
}
else {
G.drawImage(new Image(RightKnight), PlayerX, PlayerY);
}
G.drawImage(new Image(PlayerCurrentSword), PlayerX + 60, PlayerY + 90);
}
if(PlayerDirection.equalsIgnoreCase("left")) {
if(!PlayerJumping) {
WalkLeftAnimation.draw(PlayerX, PlayerY, SpriteSheetWidth, SpriteSheetHeight);
}
else {
G.drawImage(new Image(LeftKnight), PlayerX, PlayerY);
}
G.drawImage(new Image(PlayerCurrentSword), PlayerX + 6, PlayerY + 90);
}
}
/* Draw his/her sword */
else {
if(PlayerDirection.equalsIgnoreCase("right")) {
G.drawImage(new Image(RightKnight), PlayerX, PlayerY);
G.drawImage(new Image(PlayerCurrentSword), PlayerX + 60, PlayerY + 90);
}
if(PlayerDirection.equalsIgnoreCase("left")) {
G.drawImage(new Image(LeftKnight), PlayerX, PlayerY);
G.drawImage(new Image(PlayerCurrentSword), PlayerX + 6, PlayerY + 90);
}
}
/* Draw his/her power level */
G.setColor(new Color(Color.blue.darker()));
G.drawString("Knight Power Level", 10, 20);
G.setColor(new Color(Color.white));
G.drawImage(new Image(Grey).getScaledCopy(100, 10), 10, 40);
G.drawImage(new Image(Blue).getScaledCopy(PlayerRegenTime, 10), 10, 40);
/* Draw his/her health level */
G.setColor(new Color(Color.red.darker()));
G.drawString("Knight Health", 10, 60);
G.setColor(new Color(Color.white));
G.drawImage(new Image(Grey).getScaledCopy(100, 10), 10, 80);
G.drawImage(new Image(Red).getScaledCopy(PlayerHealth, 10), 10, 80);
/* Draw his/her name */
G.setColor(new Color(Color.red.darker()));
G.drawString("You\n |\n\\ /", PlayerX + 50, PlayerY - 70);
G.setColor(new Color(Color.white));
//Enemy
if(EnemyWalking) {
if(EnemyDirection.equalsIgnoreCase("right")) {
if(!EnemyJumping) {
WalkRightAnimation.draw(EnemyX, EnemyY, SpriteSheetWidth, SpriteSheetHeight);
}
else {
G.drawImage(new Image(RightKnight), EnemyX, EnemyY);
}
G.drawImage(new Image(EnemyCurrentSword), EnemyX + 60, EnemyY + 90);
}
if(EnemyDirection.equalsIgnoreCase("left")) {
if(!EnemyJumping) {
WalkLeftAnimation.draw(EnemyX, EnemyY, SpriteSheetWidth, SpriteSheetHeight);
}
else {
G.drawImage(new Image(LeftKnight), EnemyX, EnemyY);
}
G.drawImage(new Image(EnemyCurrentSword), EnemyX + 6, EnemyY + 90);
}
}
/* Draw enemy sword */
else {
if(EnemyDirection.equalsIgnoreCase("right")) {
if(!EnemyAttacking) {
EnemyCurrentSword = EnemyRightSword;
}
G.drawImage(new Image(RightKnight), EnemyX, EnemyY);
G.drawImage(new Image(EnemyCurrentSword), EnemyX + 60, EnemyY + 90);
}
if(EnemyDirection.equalsIgnoreCase("left")) {
if(!EnemyAttacking) {
EnemyCurrentSword = EnemyLeftSword;
}
G.drawImage(new Image(LeftKnight), EnemyX, EnemyY);
G.drawImage(new Image(EnemyCurrentSword), EnemyX + 6, EnemyY + 90);
}
}
/* Draw enemy power level */
G.setColor(new Color(Color.blue.darker()));
G.drawString("Enemy Power Level", 1115, 20);
G.setColor(new Color(Color.white));
G.drawImage(new Image(Grey).getScaledCopy(100, 10), 1165, 40);
G.drawImage(new Image(Blue).getScaledCopy(EnemyRegenTime, 10), 1165, 40);
/* Draw enemy health level */
G.setColor(new Color(Color.red.darker()));
G.drawString("Enemy Health", 1115, 60);
G.setColor(new Color(Color.white));
G.drawImage(new Image(Grey).getScaledCopy(100, 10), 1165, 80);
G.drawImage(new Image(Red).getScaledCopy(EnemyHealth, 10), 1165, 80);
// System Info (Not used currently)
/*G.drawString("Game State: " + this.getID(), 10, 30);
G.drawString("X:" + Mouse.getX() + " Y:" + Mouse.getY(), 10, 50);
G.drawString("Your OS: " + operatingSystem, 10, 70);
G.drawString("Player X: " + PlayerY + " Enemy X:" + EnemyX, 10, 170);*/
}
@Override
public void update(GameContainer GameContainer, StateBasedGame SBG,
int Delta) throws SlickException {
// Fixes for some stuff that might happen
if(PlayerY > 470) {
PlayerY = 470;
}
if(EnemyY > 470) {
EnemyY = 470;
}
// Enemy
if(!EnemyTalking) {
new Thread(new startFight()).start();
EnemyTalking = true;
}
/* Boss Battle Music */
if(startBossBattle && !startedBossBattle) {
if(!startedBossMusic) {
PlaySound.playSound("res/sounds/events/BossBattleLoop.wav");
PlaySound.startLoop(1000);
startedBossMusic = true;
}
startedBossBattle = true;
}
// Player
/* Player Movement */
if(PlayerCanMove) {
Input playerInput = GameContainer.getInput();
if(playerInput.isKeyDown(Input.KEY_A)) {
PlayerX -= Delta*.3f;
PlayerWalking = true;
PlayerDirection = "left";
if(!PlayerAttacking) {
PlayerCurrentSword = PlayerLeftSword;
}
}
else if(playerInput.isKeyDown(Input.KEY_D)) {
PlayerX += Delta*.3f;
PlayerWalking = true;
PlayerDirection = "right";
if(!PlayerAttacking) {
PlayerCurrentSword = PlayerRightSword;
}
}
else {
PlayerWalking = false;
}
/* Player Jumping */
if(playerInput.isKeyPressed(Input.KEY_SPACE)) {
if(!PlayerJumped) {
new Thread(new playerJump()).start();
}
}
if(PlayerJumping) {
PlayerY -= Delta*.5f;
AmountPlayerJumped = PlayerY;
}
else {
if(PlayerY < 470) {
PlayerY += Delta*.5f;
}
if(Math.round(PlayerY) == 470 || Math.round(PlayerY) == 471) {
PlayerJumped = false;
}
}
/* Player Attack */
if(playerInput.isKeyPressed(Input.KEY_ENTER)) {
if(PlayerCanAttack) {
new Thread(new playerAttack()).start();
}
else {
}
}
}
/* Player Collision Detection */
if(PlayerX < 0) {
PlayerX = 0;
}
if (PlayerX > 1155) {
PlayerX = 1155;
}
//Enemy
/* Enemy Movement and Jumping */
if(EnemyCanMove) {
if(PlayerX < EnemyX) {
if(PlayerDirection.equalsIgnoreCase("right")) {
if(!(EnemyX - 125 < PlayerX)) {
EnemyX -= Delta*.2f;
EnemyDirection = "right";
EnemyWalking = true;
BothTouching = false;
if(!(EnemyX - 50 < PlayerX)) {
if(!DecidedJump) {
int Jump = GenerateNumber.generateNumber(JumpPossibility);
if(Jump == JumpPossibility) {
new Thread(new enemyJump()).start();
}
DecidedJump = true;
}
}
else {
DecidedJump = false;
}
}
else {
EnemyWalking = false;
BothTouching = true;
if(EnemyRegenTime == 100) {
if(EnemyCanAttack) {
new Thread(new enemyAttack()).start();
}
}
}
}
if(PlayerDirection.equalsIgnoreCase("left")) {
if(!(EnemyX - 110 < PlayerX)) {
EnemyX -= Delta*.2f;
EnemyDirection = "left";
EnemyWalking = true;
BothTouching = false;
if(!(EnemyX + 50 < PlayerX)) {
if(!DecidedJump) {
int Jump = GenerateNumber.generateNumber(JumpPossibility);
if(Jump == JumpPossibility) {
new Thread(new enemyJump()).start();
}
DecidedJump = true;
}
}
else {
DecidedJump = false;
}
}
else {
EnemyWalking = false;
BothTouching = true;
if(EnemyRegenTime == 100) {
if(EnemyRegenTime == 100) {
if(EnemyCanAttack) {
new Thread(new enemyAttack()).start();
}
}
}
}
}
EnemyDirection = "left";
}
if(PlayerX > EnemyX) {
if(PlayerDirection.equalsIgnoreCase("right")) {
if(!(EnemyX + 119 > PlayerX)) {
EnemyX += Delta*.2f;
EnemyDirection = "right";
EnemyWalking = true;
BothTouching = false;
if(!(EnemyX - 50 < PlayerX)) {
if(!DecidedJump) {
int Jump = GenerateNumber.generateNumber(JumpPossibility);
if(Jump == JumpPossibility) {
new Thread(new enemyJump()).start();
}
DecidedJump = true;
}
}
else {
DecidedJump = false;
}
}
else {
EnemyWalking = false;
BothTouching = true;
if(EnemyRegenTime == 100) {
if(EnemyRegenTime == 100) {
if(EnemyCanAttack) {
new Thread(new enemyAttack()).start();
}
}
}
}
}
if(PlayerDirection.equalsIgnoreCase("left")) {
if(!(EnemyX + 135 > PlayerX)) {
EnemyX += Delta*.2f;
EnemyDirection = "left";
EnemyWalking = true;
BothTouching = false;
if(!(EnemyX + 50 < PlayerX)) {
if(!DecidedJump) {
int Jump = GenerateNumber.generateNumber(JumpPossibility);
if(Jump == JumpPossibility) {
new Thread(new enemyJump()).start();
}
DecidedJump = true;
}
}
else {
DecidedJump = false;
}
}
else {
EnemyWalking = false;
BothTouching = true;
if(EnemyRegenTime == 100) {
if(EnemyRegenTime == 100) {
if(EnemyCanAttack) {
new Thread(new enemyAttack()).start();
}
}
}
}
}
EnemyDirection = "right";
}
/* Enemy Jumping */
if(EnemyJumping) {
EnemyY -= Delta*.5f;
AmountEnemyJumped = EnemyY;
}
else {
if(EnemyY < 470) {
EnemyY += Delta*.5f;
}
if(Math.round(EnemyY) == 470 || Math.round(EnemyY) == 471) {
EnemyJumped = false;
}
}
}
}
// Initializing Constructor
@Override
public void init(GameContainer GameContainer, StateBasedGame SBG)
throws SlickException {
WalkRightSpriteSheet = new SpriteSheet("res/images/characters/knight/spritesheets/WalkAnimationRight.png", 35, 48);
WalkRightAnimation = new Animation(WalkRightSpriteSheet, 100);
WalkLeftSprite = new SpriteSheet("res/images/characters/knight/spritesheets/WalkAnimationLeft.png", 35, 48);
WalkLeftAnimation = new Animation(WalkLeftSprite, 100);
}
// Gets the ID of the current State
@Override
public int getID() {
return 1;
}
// Start Fight
static class startFight implements Runnable {
@Override
public void run() {
try {
Thread.sleep(1000);
startBossBattle = true;
} catch (Exception e) {
e.printStackTrace();
}
}
}
// Player Threads
/* Player Attack */
static class playerAttack implements Runnable {
@Override
public void run() {
try {
PlayerAttacking = true;
if(PlayerDirection.equalsIgnoreCase("right")) {
PlayerCurrentSword = PlayerRightAttackSword;
}
if(PlayerDirection.equalsIgnoreCase("left")) {
PlayerCurrentSword = PlayerLeftAttackSword;
}
if(BothTouching) {
EnemyHealth -= 10;
}
Thread.sleep(100);
if(PlayerDirection.equalsIgnoreCase("right")) {
PlayerCurrentSword = PlayerRightSword;
}
if(PlayerDirection.equalsIgnoreCase("left")) {
PlayerCurrentSword = PlayerLeftSword;
}
PlayerAttacking = false;
PlayerCanAttack = false;
PlayerRegenTime = 0;
while(PlayerRegenTime != 100) {
Thread.sleep(100);
PlayerRegenTime++;
}
PlayerCanAttack = true;
}
catch (Exception e) {
}
}
}
/* Player Jump */
static class playerJump implements Runnable {
@Override
public void run() {
try {
PlayerJumped = true;
PlayerJumping = true;
Thread.sleep(750);
PlayerJumping = false;
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
// Enemy Threads
/* Enemy Attack */
static class enemyAttack implements Runnable {
@Override
public void run() {
try {
EnemyAttacking = true;
if(EnemyDirection.equalsIgnoreCase("right")) {
EnemyCurrentSword = EnemyRightAttackSword;
}
if(EnemyDirection.equalsIgnoreCase("left")) {
EnemyCurrentSword = EnemyLeftAttackSword;
}
PlayerHealth -= 10;
Thread.sleep(100);
if(EnemyDirection.equalsIgnoreCase("right")) {
EnemyCurrentSword = EnemyRightSword;
}
if(EnemyDirection.equalsIgnoreCase("left")) {
EnemyCurrentSword = EnemyLeftSword;
}
EnemyAttacking = false;
EnemyCanAttack = false;
EnemyRegenTime = 0;
while(EnemyRegenTime != 100) {
Thread.sleep(100);
EnemyRegenTime++;
}
EnemyCanAttack = true;
}
catch (Exception e) {
e.printStackTrace();
}
}
}
/* Decide Jump */
static class decideJump implements Runnable {
@Override
public void run() {
try {
Thread.sleep(1000 * 10);
int number = GenerateNumber.generateNumber(20);
if(number == 20) {
if(!EnemyJumping) {
new Thread(new enemyJump()).start();
}
}
}
catch (Exception e) {
e.printStackTrace();
}
}
}
/* Enemy Jump */
static class enemyJump implements Runnable {
@Override
public void run() {
try {
EnemyJumped = true;
EnemyJumping = true;
Thread.sleep(750);
EnemyJumping = false;
}
catch (Exception e) {
}
}
}
最佳答案
事实证明,我没有将其添加到构建路径中。如果您正在查看此问题,请确保将其添加到 Eclipse(或 netbeans)中的构建路径。
关于java - Slick2D 即使图像存在也不会加载图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25655721/
我正在编写一个具有以下签名的 Java 方法。 void Logger(Method method, Object[] args); 如果一个方法(例如 ABC() )调用此方法 Logger,它应该
我是 Java 新手。 我的问题是我的 Java 程序找不到我试图用作的图像文件一个 JButton。 (目前这段代码什么也没做,因为我只是得到了想要的外观第一的)。这是我的主课 代码: packag
好的,今天我在接受采访,我已经编写 Java 代码多年了。采访中说“Java 垃圾收集是一个棘手的问题,我有几个 friend 一直在努力弄清楚。你在这方面做得怎么样?”。她是想骗我吗?还是我的一生都
我的 friend 给了我一个谜语让我解开。它是这样的: There are 100 people. Each one of them, in his turn, does the following
如果我将使用 Java 5 代码的应用程序编译成字节码,生成的 .class 文件是否能够在 Java 1.4 下运行? 如果后者可以工作并且我正在尝试在我的 Java 1.4 应用程序中使用 Jav
有关于why Java doesn't support unsigned types的问题以及一些关于处理无符号类型的问题。我做了一些搜索,似乎 Scala 也不支持无符号数据类型。限制是Java和S
我只是想知道在一个 java 版本中生成的字节码是否可以在其他 java 版本上运行 最佳答案 通常,字节码无需修改即可在 较新 版本的 Java 上运行。它不会在旧版本上运行,除非您使用特殊参数 (
我有一个关于在命令提示符下执行 java 程序的基本问题。 在某些机器上我们需要指定 -cp 。 (类路径)同时执行java程序 (test为java文件名与.class文件存在于同一目录下) jav
我已经阅读 StackOverflow 有一段时间了,现在我才鼓起勇气提出问题。我今年 20 岁,目前在我的家乡(罗马尼亚克卢日-纳波卡)就读 IT 大学。足以介绍:D。 基本上,我有一家提供簿记应用
我有 public JSONObject parseXML(String xml) { JSONObject jsonObject = XML.toJSONObject(xml); r
我已经在 Java 中实现了带有动态类型的简单解释语言。不幸的是我遇到了以下问题。测试时如下代码: def main() { def ks = Map[[1, 2]].keySet()
一直提示输入 1 到 10 的数字 - 结果应将 st、rd、th 和 nd 添加到数字中。编写一个程序,提示用户输入 1 到 10 之间的任意整数,然后以序数形式显示该整数并附加后缀。 public
我有这个 DownloadFile.java 并按预期下载该文件: import java.io.*; import java.net.URL; public class DownloadFile {
我想在 GUI 上添加延迟。我放置了 2 个 for 循环,然后重新绘制了一个标签,但这 2 个 for 循环一个接一个地执行,并且标签被重新绘制到最后一个。 我能做什么? for(int i=0;
我正在对对象 Student 的列表项进行一些测试,但是我更喜欢在 java 类对象中创建硬编码列表,然后从那里提取数据,而不是连接到数据库并在结果集中选择记录。然而,自从我这样做以来已经很长时间了,
我知道对象创建分为三个部分: 声明 实例化 初始化 classA{} classB extends classA{} classA obj = new classB(1,1); 实例化 它必须使用
我有兴趣使用 GPRS 构建车辆跟踪系统。但是,我有一些问题要问以前做过此操作的人: GPRS 是最好的技术吗?人们意识到任何问题吗? 我计划使用 Java/Java EE - 有更好的技术吗? 如果
我可以通过递归方法反转数组,例如:数组={1,2,3,4,5} 数组结果={5,4,3,2,1}但我的结果是相同的数组,我不知道为什么,请帮助我。 public class Recursion { p
有这样的标准方式吗? 包括 Java源代码-测试代码- Ant 或 Maven联合单元持续集成(可能是巡航控制)ClearCase 版本控制工具部署到应用服务器 最后我希望有一个自动构建和集成环境。
我什至不知道这是否可能,我非常怀疑它是否可能,但如果可以,您能告诉我怎么做吗?我只是想知道如何从打印机打印一些文本。 有什么想法吗? 最佳答案 这里有更简单的事情。 import javax.swin
我是一名优秀的程序员,十分优秀!