Results 1 to 15 of 15
Thread: declaring Classes
- 07-26-2010, 02:41 PM #1
Member
- Join Date
- Jul 2010
- Posts
- 6
- Rep Power
- 0
declaring Classes
Hi
Sorry in advanced if this is in the section or posted already but i cant find any thing :p
i have done some programming in c sharp in the past and now trying to learn java,
i have decided to build my 1st year project again which is an order system that can import and export to a txt file.
at the moment i am a little stuck with declaring a new instance of the class i have created.
once created i was thinking of adding the instance to an array.
in c" i wrote classname order = new classname();
then add the 'order' to an arraylist,
can i do this in java?
any hints or tips would b gratefully received.
thanks
dan
- 07-26-2010, 02:46 PM #2
Yes, you can do that in Java.
Trail: Learning the Java Language (The Java™ Tutorials)Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
The Ubiquitous Newbie Tips
- 07-26-2010, 02:49 PM #3
Member
- Join Date
- Jul 2010
- Posts
- 6
- Rep Power
- 0
thanks is that they way i shoudl write it because is i write that i get an error stating cannot find symbol, fixing importing, fixed half of it but not the order() bit. thanks
- 07-26-2010, 03:49 PM #4
Please copy and paste error here.i get an error
- 07-26-2010, 07:39 PM #5
Member
- Join Date
- Jul 2010
- Posts
- 6
- Rep Power
- 0
Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: Uncompilable source code - cannot find symbol
symbol: constructor Orders()
location: class mealdel.Orders
code: Orders food = new Orders(); underlined getts the error
{
food.Name(strName);
}
thanks
- 07-26-2010, 07:50 PM #6
When posting errors, please copy and paste all of it. Your edited version leaves off info.
Where is the Orders class defined? Does it have a no arg constructor?
- 07-26-2010, 10:27 PM #7
Member
- Join Date
- Jul 2010
- Posts
- 6
- Rep Power
- 0
sorry, im new to forums ;)
Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: Uncompilable source code - cannot find symbol
symbol: constructor Orders()
location: class mealdel.Orders
at Home.jButtonExportMouseClicked(Home.java:139)
at Home.access$000(Home.java:19)
at Home$1.mouseClicked(Home.java:71)
at java.awt.AWTEventMulticaster.mouseClicked(AWTEvent Multicaster.java:253)
at java.awt.Component.processMouseEvent(Component.jav a:6351)
at javax.swing.JComponent.processMouseEvent(JComponen t.java:3267)
at java.awt.Component.processEvent(Component.java:611 3)
at java.awt.Container.processEvent(Container.java:208 5)
at java.awt.Component.dispatchEventImpl(Component.jav a:4714)
at java.awt.Container.dispatchEventImpl(Container.jav a:2143)
at java.awt.Component.dispatchEvent(Component.java:45 44)
at java.awt.LightweightDispatcher.retargetMouseEvent( Container.java:4618)
at java.awt.LightweightDispatcher.processMouseEvent(C ontainer.java:4291)
at java.awt.LightweightDispatcher.dispatchEvent(Conta iner.java:4212)
at java.awt.Container.dispatchEventImpl(Container.jav a:2129)
at java.awt.Window.dispatchEventImpl(Window.java:2478 )
at java.awt.Component.dispatchEvent(Component.java:45 44)
at java.awt.EventQueue.dispatchEvent(EventQueue.java: 635)
at java.awt.EventDispatchThread.pumpOneEventForFilter s(EventDispatchThread.java:296)
at java.awt.EventDispatchThread.pumpEventsForFilter(E ventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForFilter(E ventDispatchThread.java:205)
at java.awt.Dialog$1.run(Dialog.java:1046)
at java.awt.Dialog$3.run(Dialog.java:1098)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.Dialog.show(Dialog.java:1096)
at java.awt.Component.show(Component.java:1563)
at java.awt.Component.setVisible(Component.java:1515)
at java.awt.Window.setVisible(Window.java:842)
at java.awt.Dialog.setVisible(Dialog.java:986)
at Home$2.run(Home.java:197)
at java.awt.event.InvocationEvent.dispatch(Invocation Event.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java: 633)
at java.awt.EventDispatchThread.pumpOneEventForFilter s(EventDispatchThread.java:296)
at java.awt.EventDispatchThread.pumpEventsForFilter(E ventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:196)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:188)
at java.awt.EventDispatchThread.run(EventDispatchThre ad.java:122)
the class is on a separate class, as a public class
dan
- 07-26-2010, 10:43 PM #8
I've never seen that error. How are you compiling and executing your program?
Where is the Orders class defined? Does it have a no arg constructor?
- 07-26-2010, 10:47 PM #9
Member
- Join Date
- Jul 2010
- Posts
- 6
- Rep Power
- 0
thanks for all your help
i dont think it has an arg constructor...
my class is defined on its on a java class file type and from my research on google is very similarly laid out to what i had done in c sharp.. is this what could be causing me my error?
thanks again
- 07-26-2010, 11:05 PM #10
Senior Member
- Join Date
- Apr 2010
- Location
- Belgrade, Serbia
- Posts
- 278
- Rep Power
- 4
Is your class private, package, public or protected?
Maybe it has a problem with "visibility" of your class.
Also maybe you have class but you don't have a real one constructor.Last edited by cselic; 07-26-2010 at 11:08 PM.
- 07-26-2010, 11:24 PM #11
We need to see the code that is creating the error. Without the source, there is no way to suggest anything. If you post anything be sure it will compile and start execution.
Partial code won't be of any use.
How are you compiling and executing your program?
-
You're posting a run-time exception when trying to run an uncompilable program, so what we really need to see is your compiler error, not your run-time exception. We also need to see your class (as was suggested above).
- 07-27-2010, 09:12 AM #13
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
I believe that's a compilation error, wrapped ina Runtime Exception thrown by whatever IDE is complaining that it can't compile the code.
So, essentially, it's a compilation problem caused by the code being unable to find an Orders() constructor. But, as you say, without the code it's almost impossible to tell.
- 07-27-2010, 10:11 AM #14
Member
- Join Date
- Jul 2010
- Posts
- 6
- Rep Power
- 0
thanks, i found the problem, there was an error with my class. dan
- 07-27-2010, 01:29 PM #15
Similar Threads
-
declaring classes
By coltragon in forum New To JavaReplies: 17Last Post: 12-21-2009, 06:20 PM -
Declaring a Queue
By rhm54 in forum New To JavaReplies: 1Last Post: 03-21-2008, 05:02 AM -
Declaring an ArrayList
By bugger in forum New To JavaReplies: 3Last Post: 01-31-2008, 07:36 PM -
Declaring Vector
By mew in forum New To JavaReplies: 1Last Post: 12-05-2007, 08:14 PM -
Declaring Enumeration
By Java Tip in forum Java TipReplies: 0Last Post: 11-04-2007, 05:59 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks