小编bar*_*une的帖子

我无法弄清楚如何设置1到100之间的随机数

我只想制作一个基本的计数器,由于某种原因,我无法弄清楚如何在1到100之间绘制一个随机数.有人可以解释一下我要做什么来绘制1到100之间的随机数吗?

这就是我想到的:

int value;
private int count = 1;

Random rand;


}
Run Code Online (Sandbox Code Playgroud)

android

7
推荐指数
1
解决办法
1万
查看次数

有人可以解释为什么我用Timer得到这个错误?

为什么我的定时器出错了?在代码下方,它说明错误是什么.我无法弄清楚我做错了什么......任何人都可以帮助我

       import java.util.Timer;
       import javax.swing.ImageIcon;
       import javax.swing.JPanel;

       /**
        *
      * @author Rich
      */
     public class Board extends JPanel implements ActionListener{
         Dude p;
        Image img;
       Timer time;

        public Board() {
         p = new Dude();
        addKeyListener(new AL());
         setFocusable(true);
          ImageIcon i = new ImageIcon("images.jpg");
          img = i.getImage();
          time = new Timer(5,this);
          time.start();
        }

        public void actionPerformed(ActionEvent e) {
        p.move();
        repaint();
         }
Run Code Online (Sandbox Code Playgroud)

基本上我得到的错误是

no  suitable constructor found for Timer(int,OurGame.Board)
constructor java.util.Timer.Timer(java.lang.String,boolean) is not applicable
  (actual argument int cannot be converted to java.lang.String by method …
Run Code Online (Sandbox Code Playgroud)

java swing timer

1
推荐指数
1
解决办法
1792
查看次数

Java将整数转换为字符串并进行计算

Can anyone explain to me why my Homework keeps retuning a value of 1.0, I asked my teacher and he tells me "langauges are very similar I do not remember in this languge -.-..... you should not be learning this because you are in java 1 not java 2" ...... anyway im trying to get ahead and teach myself

              /**
 *  Author Rich Talcik, Do not Edit or modify
 *  Homework assignment2 
 *  09/11/13
 *  Problem 2.7 page 109
 * …
Run Code Online (Sandbox Code Playgroud)

java string integer jtextfield

0
推荐指数
1
解决办法
154
查看次数

标签 统计

java ×2

android ×1

integer ×1

jtextfield ×1

string ×1

swing ×1

timer ×1