为什么Intellij不识别我输入的内容? BlueJ很容易识别相同的代码?
我是一个绝对的初学者。 我在高中学到了一些Java,那时我们正在使用BlueJ。
我想刷一下,所以我从最简单的代码开始:
public class HelloWorld
{
public static void main (String[] args)
{
System.out.println ("Hello World");
}
}
但是现在我使用的是Intellij,它不识别代码,因此没有在编辑器窗口范围的左侧显示运行按钮。 我在线看到教程,讲师键入了完全相同的代码,并在左侧有绿色按钮以运行Java文件,但我只是找不到。此外,如果我尝试使用主选项栏进行运行,它无能为力!
我尝试了BlueJ,它很容易运行。所以我现在很困惑。 BlueJ会在我键入并更改文本的颜色时会识别,但是Intellij并没有更改文本的颜色,这意味着它并不是真正识别该代码?有人可以解释吗?
I'm an absolute beginner.
I learnt a bit of Java in my highschool and we were using BlueJ back then.
I wanted to brush up so I started with the simplest code:
public class HelloWorld
{
public static void main (String[] args)
{
System.out.println ("Hello World");
}
}
But now I'm using intelliJ and it didn't recognise the code and as a result isn't showing the run button on the left of my editor window margin.
I saw the tutorials online and the instructor typed the exact same code and had green buttons at the left the code to run the Java file but I'm just not able to find that. Moreover if I try running it anyway using the main options bar, it doesn't do anything!
I tried this in BlueJ and it easily ran. So I'm confused now.
BlueJ would recognise as I typed and changed the colors of the text but intelliJ isn't changing the color of the text which means it isn't really recognising that code? Can someone please explain?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我发现了我的错误。
显然,通过右键单击名为“ SRC”的选项(位于项目名称下的选项解决问题)来创建新类。
到现在为止,我并没有真正单击“ SRC”,我只是任意右键单击任何地方,从未真正注意到。我认为它会在必要时自动创建我的Java类,但显然不会发生。
它准确地创建了我的班级。
我想在“ SRC”文件/选项之外创建它不允许识别。
I found out my mistake.
Apparently, creating a new class by right clicking on the option named 'src' (which is located under the project name solves the problem.
Until now I wasn't really right clicking on 'src' I would just arbitrarily right click anywhere and never really noticed. I thought it'd create my Java class automatically wherever necessary but apparently that doesn't happen.
It creates my class exactly where I ask to.
I guess creating it outside the 'src' file/option doesn't allow for the recognition.
对于Intellij,自定义主题插件可以更改文本的颜色,以帮助识别变量,方法等,但是对于代码完成,请确保您点击CTRL +空间,以要求Intellij进行建议的代码完成。
同样,您的代码设置错误,请尝试一下:
For Intellij a custom theme plugin can change the color of the text to help with recognizing variables, methods and so, but for code completion make sure that you hit ctrl + space to ask intellij for suggested code completion.
Also it looks that your code is setup wrong, give this a try:
您无需单击绿色播放按钮。有一个快捷方式可以运行您正在工作的课程,它和do alt+shift+f10 一样简单,您的代码将在中间运行。
如果您很难记住快捷方式,则查看顶部栏,可以看到“运行”选项卡。您会发现 run 按钮,它的操作与快捷方式相同。
希望这会有所帮助。
You do not need to click on the green play button. There is a shortcut to run the class you are working, it is just as simple as do ALT+Shift+F10, and your code will run inmediatly.
If you find difficult to remember shortcuts, if you look at the top bar, you can see the Run tab. You will find the Run button, which does the same as the shortcut.
Hope this helps.