2 Replies - 962 Views - Last Post: 08 December 2010 - 06:38 AM Rate Topic: -----

#1 paniraj s  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 08-December 10

'class' or 'interface' expected

Posted 08 December 2010 - 03:51 AM

Dear Sir,
i am getting this error message while importing
my code is as follows:
import javax.swing.*;
	import javax.swing.border.*;
	import java.applet.*;
	import java.awt.*;
	import java.awt.event.*;
	import java.io.*;
	import java.net.*;
	import java.util.*;
	import java.util.StringTokenizer;


im getting error in line no3,4,5,6,7,8 &9 as 'class' or 'interface' expected. pl help me.
paniraj

This post has been edited by macosxnerd101: 08 December 2010 - 08:09 AM
Reason for edit:: Please use code tags


Is This A Good Question/Topic? 0
  • +

Replies To: 'class' or 'interface' expected

#2 masijade  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 196
  • View blog
  • Posts: 580
  • Joined: 03-April 10

Re: 'class' or 'interface' expected

Posted 08 December 2010 - 04:01 AM

It looks as though you are attempting to define multiple classes in the same file and these imports are appearing between the two class definitions. You can't do that. Put all imports at the top of the file below the (one and only) package line, and before the first class line.

This post has been edited by masijade: 08 December 2010 - 04:02 AM

Was This Post Helpful? 0
  • +
  • -

#3 DaneAU  Icon User is offline

  • Great::Southern::Land
  • member icon

Reputation: 286
  • View blog
  • Posts: 1,620
  • Joined: 15-May 08

Re: 'class' or 'interface' expected

Posted 08 December 2010 - 06:38 AM

If you only have that in a file then you will more than likely get an error. You must have a class that corresponds to the file name. So at minimum you must have the following with filename Foo.java as an example

import javax.swing.*;
import javax.swing.border.*;
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
import java.util.*;
import java.util.StringTokenizer;

class Foo {


}

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1