方法If(boolean)未定义类型 [英] The method If(boolean) is undefined for the type

查看:283
本文介绍了方法If(boolean)未定义类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Eclipse一直给我以下错误:

Eclipse keeps giving me the following error:

Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
input cannot be resolved
The method If(boolean) is undefined for the type bai1DinhLuatCuLong
Syntax error, insert ";" to complete Statement
F cannot be resolved to a variable

我不明白这一点。我需要修理什么?为什么我不能使用 If()函数?

I do not understand this. What do I need to fix? Why can't I use the If() function?

我试过浏览Google和Bing,我已经仔细检查了我的Java示例书,但我无法解决这个问题。

I've tried looking through Google and Bing, and I've double checked my Java examples book, but I could not work this out.

import java.util.Scanner;


public class bai1DinhLuatCuLong
{
    public static void main(String[] args)
    { 
    System.out.print("Giá trì cần tìm (F // q // r) : ");   
    char cantim = input.nextChar();

            // HERE THIS IS WHERE I PUT THE IF STATEMENT !!!
    If (cantim == 'F') {

        Scanner input = new Scanner(System.in); 
        System.out.print("Độ lớn của điện tích thứ nhất : ");
        double q1 = input.nextDouble();
        System.out.print("Độ lớn của điện tích thứ hai : ");
        double q2 = input.nextDouble();
        System.out.print("Khoảng cách giữa 2 điện tích : ");
        double r = input.nextDouble();
        System.out.print("Hệ số k sẽ tự động được đặt là 9*10^9 như trong hệ SI");
        double F = 9 * Math.pow(10,9) * Math.abs(q1) * Math.abs(q2) / Math.pow(r,2);
    }

    System.out.print("Độ lớn lực tương tác giữa 2 điện tích điểm : " + "\n Lưu ý E là *10");

    }
}


推荐答案

如果在java中没有大上限 I :它应该是如果

If does not have a large cap I in java: it should be if.

这篇关于方法If(boolean)未定义类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆