java类型不匹配:无法从int转换为boolean

时间:2017-08-17 08:06:10

标签: java variables

我遇到了我的代码问题我有错误类型不匹配:无法从int转换为boolean我将在for循环中使用的变量这里是代码

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Image;
import java.awt.event.KeyListener;

import javax.swing.ImageIcon;
import javax.swing.JPanel;

public class Game extends JPanel{
private int widht = 300;
private int height = 300;

private Image apple;
private Image Head;
private Image Tail;

private int Tail_amount = 3;


public Board(){
    addKeyListener((KeyListener) new snakelistener());
    setPreferredSize(new Dimension(widht, height));
    setFocusable(true);
    setBackground(Color.DARK_GRAY);

    ImageIcon Icon_apple = new ImageIcon("apple.png");
    ImageIcon Icon_Head = new ImageIcon("Head.png");
    ImageIcon Icon_Tail = new ImageIcon("Tail.png");

    apple = Icon_apple.getImage();
    Head = Icon_Head.getImage();
    Tail = Icon_Tail.getImage();

    for(int i = 0; i = < Tail_amount; i++);


}
}

如果你能帮助我,那就帮助我

lg coolian

3 个答案:

答案 0 :(得分:3)

你的循环条件中的操作符错误。将其更改为:

<?php

                              $taxonomyName =get_query_var( 'product_cat' ); // use use get_queried_object()->taxonomy; to get the current taxonomy name
                              $countchildren = count (get_term_children( $term_id, $taxonomyName ));

                     echo '<h3 class="group-products mts mbm  cat-title text-underline">'.'<span class="big">'.'Products Families'.'<span class="cont-post">'.'(' .$countchildren.')'.'</span>'.'</span>'.'</h3>';

                    ?>   

答案 1 :(得分:1)

你的问题在于循环本身,所以不是:

    for(int i = 0; i = < Tail_amount; i++)

你需要:

    for(int i = 0; i <= Tail_amount; i++)

交换运算符,因为这是检查i是否小于或等于Tail_amount的正确语法。

答案 2 :(得分:0)

乍一看,我看到了以下问题

tr