Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
227 views
in Technique[技术] by (71.8m points)

java - The method If(boolean) is undefined for the type

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

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

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 : " + "
 L?u y E là *10");

    }
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...