• Post Reply Bookmark Topic Watch Topic
  • New Topic

java:103: error: illegal start of expression  RSS feed

 
Hemanth Reddy
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am writing this small code to implement JDBC with an application using frames and swings. I tried putting in JTabbedpane and its showing an error which I'm not able to find out.



The errors :

Application.java:24: error: illegal start of expression
public class Createdata extends JPanel
^
Application.java:103: error: illegal start of expression
public class Attendance extends JPanel
^
2 errors
 
Greg Brannon
Bartender
Posts: 563
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't start/define a class inside a method.
 
Hemanth Reddy
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm sorry but I tried many different ways. Could you just alter this code and give it plss.
 
Hemanth Reddy
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok to avoid that I used panels instead but they don't appear *PULLS HAIR*. The frame is appearing with the setsize, but nothing appears inside the frame.

 
Greg Brannon
Bartender
Posts: 563
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Line 17 begins a method, Lines 24 and 103 begin new classes (with method code intermixed), and line 128 ends the method that began at line 17. Move the classes outside the method. Your code seems to be suffering the effects of copy and paste operations that were not executed with due consideration of proper Java code structure. Remove the invading class code from the violated method to a nested location within the Application class, at the same level as Application (they can't be public), or into another file entirely.
 
Hemanth Reddy
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a million. Did the job !
 
Greg Brannon
Bartender
Posts: 563
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Glad to help. Keep coding.
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greg Brannon wrote:You can't start/define a class inside a method.

Yes you can. Those are called method-local classes. However, they can't have any modifiers other than abstract, final and strictfp - no public, private, protected or static.
 
Greg Brannon
Bartender
Posts: 563
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes you can. Those are called method-local classes. However, they can't have any modifiers other than abstract, final and strictfp - no public, private, protected or static.

Thanks. I realized my statement was incorrect by being too general, and I meant to clarify, but forgot.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!