热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

无法解析为类型?-Cannotberesolvedtoatype?

SoIhavebeenprogrammingforallof4hours,Iamusingathistutorialhttp:www.vogella.comart

So I have been programming for all of 4 hours, I am using a this tutorial http://www.vogella.com/articles/Eclipse/article.html#eclipseoverview. when after copying the code I got an error cannot be resolved to a type. I then did what all my friends told me to do, look at the code. I spent an hour making sure mine looked like his.

所以我已经编程了4个小时,我使用的是这个教程http://www.vogella.com/articles/Eclipse/article.html#eclipseoverview。在后,我得到的错误不能被解析为类型。然后我做了我所有的朋友让我做的事情,看看代码。我花了一个小时来确定我的看起来像他的。

the program is supposed to print hello world on to the screen. here is my attempt at it:

该程序应该在屏幕上打印hello world。下面是我的尝试:

package de.vogella.eclipse.ide.first;
public class myFirstClass {
    public static void main(string[] args) {
        System.out.println("hello eclipse");
    }
}

In eclipse the word string is highlighted and it says that it cant be resolved to a type. I have also tried another java tutorial, Java total beginners, and this same problem appears. Any help would be appreciated, I'm totally new to programming, I try to learn more by using tutorials but this keeps stopping me (i know catch 22. Any advice that could help me get past this would be great, advice or maybe a question that already covered this any help would be great!!

在eclipse中,单词字符串被突出显示,并表示不能将其解析为类型。我还尝试了另一个java教程,java完全初学者,这个问题也出现了。任何帮助都是值得感激的,我对编程完全陌生,我尝试通过使用教程来学习更多,但这一直阻止我(我知道catch 22。任何能帮我度过这段时间的建议都是很好的建议,或者是一个已经涵盖了这一切的问题,将会是非常棒的!!

4 个解决方案

#1


2  

public class myFirstClass {
    public static void main(string[] args) {
        System.out.println("hello eclipse");
    }
}

should be

应该是

public class myFirstClass {
    public static void main(String[] args) { 
        System.out.println("hello eclipse");
    }
}

#2


4  

Use String not string.

使用字符串而不是字符串。

public static void main(String[] args) { System.out.println("hello eclipse"); }

Java classes are case sensitive. String is the class you need.

Java类是区分大小写的。字符串是您需要的类。

#3


0  

"cannot be resolved to a type" means that the compiler has decided that, according to the syntax of the language, what it found at this place in the code has to be type, which means either a class, an interface, or a primitive tpye, but cannot find the definition of any type with that name.

“不能解决一个类型”意味着编译器已经决定,根据语言的语法,它在这个地方找到代码中的类型,这意味着一个类,接口,或原始打字,但无法找到任何类型的定义与这个名字。

In this case, "string" cannot be resolved because there is no such type - Java is case sensitive, and the class is named String. There is an extremely strong convention for class names to start with an uppercase letter. The only lowercase types you'll normally encounter are the primitive types like int and boolean.

在这种情况下,“string”不能被解析,因为没有这样的类型—Java是区分大小写的,类是命名字符串。对于类名,有一种非常强的约定以大写字母开头。您通常会遇到的唯一的小写类型是int和boolean等基本类型。

When you get this error the typical reasons are:

当你得到这个错误的时候,典型的原因是:

  • you mistyped the name of the type
  • 你把字体的名字弄错了。
  • or the package in the import statement is wrong
  • 或者导入语句中的包是错误的。
  • or you have a problem with the classpath.
  • 或者你对类路径有问题。

#4


0  

As per the Java language Specification the signature of main() method takes a parameter of String array. As Java is case sensitive and there is no such type/class called "string" thus it is giving you the said error. We have "String" as a class in java which should be present over there as "String[] args".

根据Java语言规范,main()方法的签名采用字符串数组的参数。由于Java是区分大小写的,所以没有所谓的“string”类型/类,因此它给出了所述错误。我们将“String”作为java中的一个类,它应该作为“String[] args”出现在那里。


推荐阅读
  • 微软头条实习生分享深度学习自学指南
    本文介绍了一位微软头条实习生自学深度学习的经验分享,包括学习资源推荐、重要基础知识的学习要点等。作者强调了学好Python和数学基础的重要性,并提供了一些建议。 ... [详细]
  • Iamtryingtomakeaclassthatwillreadatextfileofnamesintoanarray,thenreturnthatarra ... [详细]
  • Java太阳系小游戏分析和源码详解
    本文介绍了一个基于Java的太阳系小游戏的分析和源码详解。通过对面向对象的知识的学习和实践,作者实现了太阳系各行星绕太阳转的效果。文章详细介绍了游戏的设计思路和源码结构,包括工具类、常量、图片加载、面板等。通过这个小游戏的制作,读者可以巩固和应用所学的知识,如类的继承、方法的重载与重写、多态和封装等。 ... [详细]
  • 原文地址:https:www.cnblogs.combaoyipSpringBoot_YML.html1.在springboot中,有两种配置文件,一种 ... [详细]
  • 本文介绍了如何在给定的有序字符序列中插入新字符,并保持序列的有序性。通过示例代码演示了插入过程,以及插入后的字符序列。 ... [详细]
  • 如何用UE4制作2D游戏文档——计算篇
    篇首语:本文由编程笔记#小编为大家整理,主要介绍了如何用UE4制作2D游戏文档——计算篇相关的知识,希望对你有一定的参考价值。 ... [详细]
  • Spring特性实现接口多类的动态调用详解
    本文详细介绍了如何使用Spring特性实现接口多类的动态调用。通过对Spring IoC容器的基础类BeanFactory和ApplicationContext的介绍,以及getBeansOfType方法的应用,解决了在实际工作中遇到的接口及多个实现类的问题。同时,文章还提到了SPI使用的不便之处,并介绍了借助ApplicationContext实现需求的方法。阅读本文,你将了解到Spring特性的实现原理和实际应用方式。 ... [详细]
  • 本文讨论了一个关于cuowu类的问题,作者在使用cuowu类时遇到了错误提示和使用AdjustmentListener的问题。文章提供了16个解决方案,并给出了两个可能导致错误的原因。 ... [详细]
  • Java String与StringBuffer的区别及其应用场景
    本文主要介绍了Java中String和StringBuffer的区别,String是不可变的,而StringBuffer是可变的。StringBuffer在进行字符串处理时不生成新的对象,内存使用上要优于String类。因此,在需要频繁对字符串进行修改的情况下,使用StringBuffer更加适合。同时,文章还介绍了String和StringBuffer的应用场景。 ... [详细]
  • XML介绍与使用的概述及标签规则
    本文介绍了XML的基本概念和用途,包括XML的可扩展性和标签的自定义特性。同时还详细解释了XML标签的规则,包括标签的尖括号和合法标识符的组成,标签必须成对出现的原则以及特殊标签的使用方法。通过本文的阅读,读者可以对XML的基本知识有一个全面的了解。 ... [详细]
  • 2018年人工智能大数据的爆发,学Java还是Python?
    本文介绍了2018年人工智能大数据的爆发以及学习Java和Python的相关知识。在人工智能和大数据时代,Java和Python这两门编程语言都很优秀且火爆。选择学习哪门语言要根据个人兴趣爱好来决定。Python是一门拥有简洁语法的高级编程语言,容易上手。其特色之一是强制使用空白符作为语句缩进,使得新手可以快速上手。目前,Python在人工智能领域有着广泛的应用。如果对Java、Python或大数据感兴趣,欢迎加入qq群458345782。 ... [详细]
  • 本文介绍了数据库的存储结构及其重要性,强调了关系数据库范例中将逻辑存储与物理存储分开的必要性。通过逻辑结构和物理结构的分离,可以实现对物理存储的重新组织和数据库的迁移,而应用程序不会察觉到任何更改。文章还展示了Oracle数据库的逻辑结构和物理结构,并介绍了表空间的概念和作用。 ... [详细]
  • 本文分享了一个关于在C#中使用异步代码的问题,作者在控制台中运行时代码正常工作,但在Windows窗体中却无法正常工作。作者尝试搜索局域网上的主机,但在窗体中计数器没有减少。文章提供了相关的代码和解决思路。 ... [详细]
  • android listview OnItemClickListener失效原因
    最近在做listview时发现OnItemClickListener失效的问题,经过查找发现是因为button的原因。不仅listitem中存在button会影响OnItemClickListener事件的失效,还会导致单击后listview每个item的背景改变,使得item中的所有有关焦点的事件都失效。本文给出了一个范例来说明这种情况,并提供了解决方法。 ... [详细]
  • 本文介绍了RPC框架Thrift的安装环境变量配置与第一个实例,讲解了RPC的概念以及如何解决跨语言、c++客户端、web服务端、远程调用等需求。Thrift开发方便上手快,性能和稳定性也不错,适合初学者学习和使用。 ... [详细]
author-avatar
夏天电艹热毯
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有