简单的Java程序但没有运行? [英] Simple Java Program but not running??

查看:188
本文介绍了简单的Java程序但没有运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我是java新手我安装了netbeans 6.0.1

我试过运行以下简单的程序,但它没有工作???



导入java.util。*;

公共类Hello

{

public static void main(String [] args)

{

扫描仪阅读器=新扫描仪(System.in);

字符串名称;


System.out.print("你的名字是什么?);

name = reader.readLine();


System.out.println(名称+我期待长期而富有成效的关系。);

}

}


我收到以下错误:


init:

deps-jar:

编译1源文件到C:\Documents and Settings \ PAAET User \ My Documents \NetBeansProjects \ JavaApplication8 \ build \ classes

C:\ Document and Settings \ PAAET User \\ \\我的文件\ NetBeansProjects \ J. avaApplication8 \ src\ja vaapplication8 \ Main.java:28:class,interface或enum expected

------------------- -------------------------------------------------- -----------

1错误

BUILD FAILED(总时间:0秒)

Hi everybody,
I am new to java I installed netbeans 6.0.1
I tried running the following simple program but it didnor work???


import java.util.*;
public class Hello
{
public static void main(String [] args)
{
Scanner reader = new Scanner(System.in);
String name;

System.out.print("What is your name? ");
name = reader.readLine();

System.out.println(name + " I look forward to a long and fruitful relationship.");
}
}

I got the following error:

init:
deps-jar:
Compiling 1 source file to C:\Documents and Settings\PAAET User\My Documents\NetBeansProjects\JavaApplication8\build\ classes
C:\Documents and Settings\PAAET User\My Documents\NetBeansProjects\JavaApplication8\src\ja vaapplication8\Main.java:28: class, interface, or enum expected
--------------------------------------------------------------------------------
1 error
BUILD FAILED (total time: 0 seconds)

推荐答案

尝试使用此代码读取名称


name = scanner.next();
Try using this code to read the name

name= scanner.next();


您向我们展示的课程不是编译的课程。


亲切的问候,


Jos
The class you have shown us is not the class that was compiled.

kind regards,

Jos



您向我们展示的课程不是编译的课程。


亲切的问候,


Jos
The class you have shown us is not the class that was compiled.

kind regards,

Jos



谢谢,但我怎么能这样做我只按绿色三角形。


Thanks but how can I do it I just press the green triangle.


这篇关于简单的Java程序但没有运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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