Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/350.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java错误:无法取消对int的引用_Java - Fatal编程技术网

Java错误:无法取消对int的引用

Java错误:无法取消对int的引用,java,Java,我正在编写一个简单的Java程序来进行温度转换,在第8行(我在下面的代码中标记了该行)上不断出现一个错误,即int不能被解引用。我不确定这到底意味着什么,或者如何修复它,这里的其他问题与相同的错误没有帮助找到解决我的错误的方法 import java.util.*; class TemperatureConversion { public TemperatureConversion() { int x = 0;

我正在编写一个简单的Java程序来进行温度转换,在第8行(我在下面的代码中标记了该行)上不断出现一个错误,即int不能被解引用。我不确定这到底意味着什么,或者如何修复它,这里的其他问题与相同的错误没有帮助找到解决我的错误的方法

import java.util.*;

class TemperatureConversion { 

        public TemperatureConversion()
        {
            int x = 0;
            x.getInput.Int("Would you like to convert from Fahrenheit to Celcius or Celcius to Fahrenheit? Enter '1' for Fahrenheit to Celcius, and 2 for Celsius to Fahrenheit.");  //This is the line with the error

            if(x == 1)
            {
                toCelsius();
            }
            if(x ==2)
            {
                toFahrenheit();
            }
        }


        public void toCelsius()
        {
                double fahrenheit = 0.0;    
                fahrenheit = Input.getDouble("Enter the temperature in Fahrenheit to be converted to Celsius.");
                System.out.println("The converted value is " + (5.0/9.0 * (fahrenheit + 32)) + " degrees Celsius.");
        }

        public void toFahrenheit()
        {
                double celsius = 0.0;
                celsius = Input.getDouble("Enter the temperature in Celsius to be converted to Fahrenheit.");
                System.out.println("The converted value is " + (9.0/5.0 * (celsius + 32)) + " degrees Fahrenheit."); 
        }

}

x是一个
int
,是一个原语,因此不能被取消引用-这意味着x。在Java中,任何东西都是无效语法

我假设您要做的是为x分配一些用户输入:

Scanner sc = new Scanner(System.in);
int x = sc.nextInt();

x是一个
int
,是一个原语,因此不能被取消引用,这意味着x。在Java中,任何东西都是无效的语法

我假设您要做的是为x分配一些用户输入:

Scanner sc = new Scanner(System.in);
int x = sc.nextInt();

x是一个
int
,是一个原语,因此不能被取消引用,这意味着x。在Java中,任何东西都是无效的语法

我假设您要做的是为x分配一些用户输入:

Scanner sc = new Scanner(System.in);
int x = sc.nextInt();

x是一个
int
,是一个原语,因此不能被取消引用,这意味着x。在Java中,任何东西都是无效的语法

我假设您要做的是为x分配一些用户输入:

Scanner sc = new Scanner(System.in);
int x = sc.nextInt();

我想知道你是从哪里想到写这个
x.getInput.Int(
fahrenheit=Input.getDouble)的(
。它们都没有使用标准的Java API。你在互联网上有没有什么来源告诉你写这些东西?你在看用不同编程语言编写的代码吗?@Stephen C,我正在上课,我的老师在说明中说用这种方法获取用户输入。通常我使用扫描仪,我明白这是做类似事情的更好方法。@Claire-看起来要么是讲师的说明不清楚,要么是你误解了。当然是在第一种情况下。(第二种情况是合理的……如果讲师提供了定义
输入的东西。)我想知道你是从哪里想到写这个
x.getInput.Int(
fahrenheit=Input.getDouble)的(
。它们都没有使用标准的Java API。你在互联网上有没有什么来源告诉你写这些东西?你在看用不同编程语言编写的代码吗?@Stephen C,我正在上课,我的老师在说明中说用这种方法获取用户输入。通常我使用扫描仪,我明白这是做类似事情的更好方法。@Claire-看起来要么是讲师的说明不清楚,要么是你误解了。当然是在第一种情况下。(第二种情况是合理的……如果讲师提供了定义
输入的东西。)我想知道你是从哪里想到写这个
x.getInput.Int(
fahrenheit=Input.getDouble)的(
。它们都没有使用标准的Java API。你在互联网上有没有什么来源告诉你写这些东西?你在看用不同编程语言编写的代码吗?@Stephen C,我正在上课,我的老师在说明中说用这种方法获取用户输入。通常我使用扫描仪,我明白这是做类似事情的更好方法。@Claire-看起来要么是讲师的说明不清楚,要么是你误解了。当然是在第一种情况下。(第二种情况是合理的……如果讲师提供了定义
输入的东西。)我想知道你是从哪里想到写这个
x.getInput.Int(
fahrenheit=Input.getDouble)的(
。它们都没有使用标准的Java API。你在互联网上有没有什么来源告诉你写这些东西?你在看用不同编程语言编写的代码吗?@Stephen C,我正在上课,我的老师在说明中说用这种方法获取用户输入。通常我使用扫描仪,我明白这是做类似事情的更好方法。@Claire-看起来要么是讲师的说明不清楚,要么是你误解了。当然是在第一种情况下。(第二种情况是合理的……如果讲师提供了定义
输入的东西。)