Solved

missing import

Posted on 2004-04-09
4
229 Views
Last Modified: 2010-03-31
Hi, im getting this error for a java file, is there something extra I need to import?
Cheers


--------------------Configuration: j2sdk1.4.0_02 <Default>--------------------
C:\output.java:5: 'class' or 'interface' expected
public String output() {
       ^
1 error

Process completed.

0
Comment
Question by:Ronayne
  • 2
4 Comments
 
LVL 13

Accepted Solution

by:
Webstorm earned 30 total points
ID: 10790897
You must put this method in a class:

public class MyClass {
  public String output() { ... }

}
0
 

Author Comment

by:Ronayne
ID: 10791018

Ah I see, thx
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10791020
In your case:

public class Output {

  public Output() { // constructor of your Output class
  }

  public String output() {
     String t = "something";  // as an example
     return t;
  }

}
0
 
LVL 13

Expert Comment

by:Webstorm
ID: 10791299
:-)

If you want to learn more about Java :
http://java.sun.com/docs/books/tutorial/index.html
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now