Solved

missing import

Posted on 2004-04-09
4
234 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delete Android all or certain applications data programmatically 9 153
Convert from a json string array to a Java object 3 81
hashmap order 17 63
Java array 10 89
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
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…
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

752 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