Results 1 to 15 of 15
  1. #1
    danderton is offline Member
    Join Date
    Jul 2010
    Posts
    6
    Rep Power
    0

    Default 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

  2. #2
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default

    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  3. #3
    danderton is offline Member
    Join Date
    Jul 2010
    Posts
    6
    Rep Power
    0

    Default

    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

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,816
    Rep Power
    25

    Default

    i get an error
    Please copy and paste error here.

  5. #5
    danderton is offline Member
    Join Date
    Jul 2010
    Posts
    6
    Rep Power
    0

    Default

    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

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,816
    Rep Power
    25

    Default

    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?

  7. #7
    danderton is offline Member
    Join Date
    Jul 2010
    Posts
    6
    Rep Power
    0

    Default

    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

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,816
    Rep Power
    25

    Default

    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?

  9. #9
    danderton is offline Member
    Join Date
    Jul 2010
    Posts
    6
    Rep Power
    0

    Default

    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

  10. #10
    cselic is offline Senior Member
    Join Date
    Apr 2010
    Location
    Belgrade, Serbia
    Posts
    278
    Rep Power
    5

    Default

    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-27-2010 at 12:08 AM.

  11. #11
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,816
    Rep Power
    25

    Default

    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?

  12. #12
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    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).

  13. #13
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,185
    Rep Power
    20

    Default

    Quote Originally Posted by Norm View Post
    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?
    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.

  14. #14
    danderton is offline Member
    Join Date
    Jul 2010
    Posts
    6
    Rep Power
    0

    Default

    thanks, i found the problem, there was an error with my class. dan

  15. #15
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,816
    Rep Power
    25

    Default

    Could you explain and show what was wrong. This error was a rare one.

Similar Threads

  1. declaring classes
    By coltragon in forum New To Java
    Replies: 17
    Last Post: 12-21-2009, 07:20 PM
  2. Declaring a Queue
    By rhm54 in forum New To Java
    Replies: 1
    Last Post: 03-21-2008, 06:02 AM
  3. Declaring an ArrayList
    By bugger in forum New To Java
    Replies: 3
    Last Post: 01-31-2008, 08:36 PM
  4. Declaring Vector
    By mew in forum New To Java
    Replies: 1
    Last Post: 12-05-2007, 09:14 PM
  5. Declaring Enumeration
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-04-2007, 06:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •