I dont see what i do wrong here.

Hi
I have a bit of a problem here. Im trying to create an object in my test class. However, Since i have some parameters in my constructor i get an error message in the test class:
Error(8,27): no declaration allowed here, use '{'
and
Error(8,34): , expected
If i remove the parametrs from the constructor, I dont get any errors. Thing is, I think there should be parameters in the contructor since its parameters that the object always has.
Here is the Classes contructor code:
public Kund(String nummer, String namn, String adress){
    order=new HashMap<String, Order>();
    setNummer(nummer);
    setNamn(namn);
    setAdress(adress);
}and here is the code from the testclass when im trying to create and object:
public static void main(String[] args) {
        Kund k = new Kund(String nummer, String namn, String adress);
        k.setNummer("125");
        k.setNamn("Peter");
        k.setAdress("Lund");and as stated above these are the error messages i get:
Error(8,27): no declaration allowed here, use '{'
Error(8,34): , expected
Anyone have a pointer to what im doing wrong?

Morpheus wrote:
On that note though..Why having both parameters and then also set and get methods in the class? Seemes like double code for the same thing.It is. It is often done for flexibility and convenience: you can either pass the values to the constructor, or use a no-argument constructor and set the values later, if you wish.
You can also use the setters to change the values, if someone's address changes for example.

Similar Messages

  • Ok so i was wondering what im doing wrong here

    i have one driver class and 2 objects that im trying to read into it. the RightArrow and LeftArrow compile but the demo class gives me these errors
    F:\ArrowDemo1.java:25: setTail(int) in RightArrow cannot be applied to ()
                   RightArrow.setTail();
                   ^
    F:\ArrowDemo1.java:29: setArrowheads(int) in LeftArrow cannot be applied to ()
         LeftArrow.setArrowheads();
         ^
    F:\ArrowDemo1.java:30: setTails(int) in LeftArrow cannot be applied to ()
         LeftArrow.setTails();
         ^
    4 errors
    what am i doing wrong here.
    public class ArrowDemo1
       public static void main(String[]args)
            Scanner keyboard = new Scanner(System.in);
            System.out.println("Do you want your arrow to point right or left");
            System.out.println("Type right or left");
            String rightLeft = keyboard.nextLine();
            if  (rightLeft.equalsIgnoreCase("right"))
                      RightArrow.setArrowhead();
                      RightArrow.setTail();
            if (rightLeft.equalsIgnoreCase("left"))
                 LeftArrow.setArrowheads();
                 LeftArrow.setTails();
    public class LeftArrow extends Figure
         Scanner keyboard = new Scanner(System.in);
         private int base;
         private int head;
         private int tail;
         public void setArrowheads(int headsUp)
              System.out.println("Please enter a head length for your arrow");
              headsUp = keyboard.nextInt();
              if (headsUp < 1)
                      System.out.println("Sorry the head length must be larger than 0");
                      System.exit(0);
              if (headsUp >= 3)
                 int oddTest = (headsUp%2);
                 if (oddTest == 0)
                      System.out.println("Sorry you must enter an odd number of 3 or higher");
                      System.exit(0);
           head = headsUp;
        public void setTails(int tail)
                   System.out.println("Please enter a tail length for your arrow");
                   tail = keyboard.nextInt();
                   if (tail < 1)
                           System.out.println("Sorry the tail length must be larger than 0");
                           System.exit(0);
    public class RightArrow extends Figure
        Scanner keyboard = new Scanner(System.in);
         private int base;
         private int head;
         private int tail;
         public void setArrowhead(int heads)
              System.out.println("Please enter a head length for your arrow");
              heads = keyboard.nextInt();
              if (heads < 1)
                      System.out.println("Sorry the head length must be larger than 0");
                      System.exit(0);
              if (heads >= 3)
                 int oddTest = (heads%2);
                 if (oddTest == 0)
                      System.out.println("Sorry you must enter an odd number of 3 or higher");
                      System.exit(0);
           head = heads;
        public void setTail(int tails)
              System.out.println("Please enter a tail length for your arrow");
              tails = keyboard.nextInt();
              if (tails < 1)
                      System.out.println("Sorry the tail length must be larger than 0");
                      System.exit(0);
            tail = tails;
    }

    duffymo wrote:
    How do you ever expect to understand Java when you can't read English?
    Did you read the error messages?This is one of the things that frustrates me the most. People see an error message, and they freak out. "OMFG! I don't know enough Java to understand these mysterious runes! I need to find someone to tell me what magic spell to type (since programming is, of course, all about memorizing what to type) to make it go away!"
    I know some of the messages are kind of cryptic, but many of them--this one being a prime example--are very explicit if you just take a few seconds to read it. Are people so bloody afraid to even try to engage their brains? Does nobody even have the most basic concept of observing a problem, taking a moment to study what's happening, using a tiny bit of knowledge, logic, and guesswork to come up with a potential solution or two, and then trying it out? Is everybody really so fuckityfucking helpless? Is simple analysis a lost art, doomed to go the way of [Damscus steelmaking|http://en.wikipedia.org/wiki/Damascus_steel]?
    </rant>
    Edited by: jverd on Mar 29, 2008 12:56 PM

  • TS2771 my ipod says"ipod is disabled, connect to itunes".  i am currently on itunes, but dont know what to do from here to get ipod to show all apps and information on the screen

    my daughters ipod currently reads"ipod is disabled, connect to itunes". i am currently connected to itunes, but im clueless as to what i need to do to get the ipod back to the normal screen that displays the main screen to be able to use the ipod properly. i have tried resetting the ipod by turning the system off and back on already, can anyone help me?!!
    thanks
    blonde mom in tennessee

    Place the iOS device in Recovery Mode and then connect to your computer and restore via iTunes. The iPod will be erased.
    iOS: Wrong passcode results in red disabled screen                          
    If recovery mode does not work try DFU mode.                         
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings         
    For how to restore:
    iTunes: Restoring iOS software
    To restore from backup see:
    iOS: How to back up
    If you restore from iCloud backup the apps will be automatically downloaded. If you restore from iTunes backup the apps and music have to be in the iTunes library since synced media like apps and music are not included in the backup of the iOS device that iTunes makes.
    You can redownload iTunes purchases by:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store

  • [Athlon64] dont know what i did wrong!!!!

     I JUST FINISHED PUTTING TOGETHER MY COMPUTER. K8T NEO2 SERIES BOARD...ATHLON 64 3200... I TURNED THE POWER ON AND I GET THIS REALLY LOUD PIRECING NOISE IT WONT STOP, I WONT KEEP THE COMPUTER ON LONG ENOUGH TO SEE IF I GET ANYTHING ON THE SCREEN, FROM WHAT I UNDERSTAND I THINK I PUT EVERYTHING TOGETHER RIGHT, BUT NOW IM NOT SURE ANYMORE. PLEASE CAN ANYONE HELP ME OUT? I AM LOST

    Is the loud noice comming from the speaker?!
    In any way, my bet would be that something is not assembled right. Double-check PSU, PSU fan, chassi fans (check that no cables are entangled in the fans), powercables, RAM modules, etc. etc...

  • HT1918 hi iv changed my credit card details and it keeps saying go to apple support 3 times iv done it and dont no what im doing wrong

    hi iv just paid my bill or tried to but it keeps saying go to support it wont let me do anything 3 times this has happened

    Because too much time has passed I can't edit this into the prior comment, but here is the info regarding reverting to iTunes 11.0.2 (assuming you do have a time machine backup) from https://discussions.apple.com/message/22057703#22057703
    W. Raider wrote:
    Repairing permissions doesn't fix it.
    I reverted to the previous version, 11.0.2.
    1. Quit the new crash-prone iTunes.
    2. Delete the app.
    3. Restore v. 11.0.2 with Time Machine.
    4. In your iTunes folder look for a folder called "Previous iTunes Libraries", find the latest one.
    5. In the iTunes folder itself you'll see "iTunes Library.itl", delete it (or compress it and save a copy for later just in case.
    6. Copy the newest .itl file in Previous iTunes Libraries to the iTunes folder and rename it "iTunes Library.itl".
    7. Launch the older version of iTunes.
    My crashing has seemed to have ceased with a revert to an older version. I noticed today that the newer crashing iTunes had been launched for hours but not playing anything, when I played internet radio it crashed within 5mins, fed up I reverted to an older version.
    Btw, a simpler way to do this is to revert to older iTunes app, then hold Option when it launches and choose an older library.

  • I seem to have lost all of my playlists and more than half my songs. How do I get them back? Dont know what I did wrong? Please Help

    I seem to have lost all my original playlists and more than half my songs. How do I get them back, where did I go wrong?
    If I was to press "restore" does this wipe everything off my library? I always thought that you could never loose songs? That they were always stored somewhere
    in there. Please help,

    If those tabs aren't in History > Recently Closed Tabs or Windows then they are probably lost.
    You can try to search them in the History if you haven't bookmarked them.
    Using the "Show my windows and tabs from last time" setting is a more reliable way to restore session data.
    * Tools > Options > General > Startup: "When Firefox Starts": "Show my windows and tabs from last time"

  • Plugin not working with firefox 4.0.1 showing an compatibilty error however it is getting installed in Firefox 3.6 successfully. Dont know what is going wrong please help on urgent basis

    Hi,
    Plugin can be loaded from the link below. This is getting installed on the firefox 3 version but each time I install it on Firefox 4 version it shows the compatibilty error. I have disabled the compatibilty check for firefox in default:config setting but still getting the same error. Please resolve asap.
    Thanks in advance

    That extension has a maxVersion of 3.*.* (3.0.* in update.rdf) and can't be installed in Firefox 4.
    <pre><nowiki><em:minVersion>1.5</em:minVersion>
    <em:maxVersion>3.*.*</em:maxVersion></nowiki></pre>

  • Can someone explain what ive done wrong here?

    Seems like im very close to solving the problem of my gallery.
    This is the link i want to appear on my website: http://www.rayoga.co.uk/gallery/
    But this is the one my website keeps sending me to: http://www.rayoga.co.uk/gallery/Gallery.html
    Where has that extra 'Gallery.html' come from and how do i get rid of it?!
    Thanks

    On your homepage change the link to point at the correct location of your gallery.
    Change this:
    <th width="112" scope="col"><a href="../../gallery/Gallery.html" title="gallery">gallery</a></th>
    To this:
    <th width="112" scope="col"><a href="../../gallery" title="gallery">gallery</a></th>

  • HT1414 i started the update and then my screen went to an apple symbol with aprogress bar, then to a picutre of a usb with arrow and itune symbol and dont know what to do from here

    i started the update on my iphone 4 and the creen went to an apple symbol with a progress bar , then to a black screen with the apple symbol and thren to a picture of a USB with arrow to itunes. how do i fix this ,end this ??????? unable to use phone

    Connect your phone to itunes and restore it by clicking the restore button, then restore from backup.

  • What could be wrong with this resolveNodes / for script?

    Hello, I am stumped and would greatly appreciate some help here.
    I have a table that has the ability to add additional rows.
    Each row includes a "delete" button to clear the row.
    I'd like to hide the "delete" button when another button is clicked.
    There are a variable amount of rows at any given time, so I can't target the button directly.
    I have used the "for" method before, but it doesn't seem to be able to find the nodes in this case.
    My hierarchy looks like this:
    form1
    - productSubform
    - - productJobTable
    - - - productJobRow
    - - - - deleteBtn
    my Javascript looks like this:
    var nodes = form1.productSubform.productJobTable.resolveNodes("productJobRow[*]");
    var len = nodes.length;
    for(var i = 0; i < len; i++) {
            nodes.item(i).deleteBtn.presence = "invisible";
    Can anyone see what could be wrong here?
    Thank you in advance.

    This code worked for me...
      var rows = form1.p1.Table1.resolveNodes("Row1[*]");
      var len = rows.length;
      for (var i=0; i<len; i++) rows.item(i).Button1.presence = "invisible";
    When I used nodes as the variable name, I got this error: "Invalid property set operation."

  • HT201441 the apple ID that i was signed into was deleted and i erased my phone, it says that the apple ID id wrong and now i dont know what to do.

    so i have erased my phone and the apple id i had was with other people and now the apple id was canceled and now it wouldnt let me sign into my phone. I dont know what to do from here?

    http://support.apple.com/kb/PH13695
    http://support.apple.com/kb/ht5818
    http://support.apple.com/kb/ts4515

  • My iphone isnt turning on or charging i dont know whats wrong with it, can anyone help me?!?!

    i dont know whats wrong with my iphone it wont turn on or charge i dont now what i did wrong please help

    Charge for 15 minutes with the wall or mains adapter. Then hold the HOME and SLEEP buttons until an Apple logo appears. If something other than an Apple logo appears follow the instructions on the screen. If nothing happens after holding for 30 seconds you have a hardware problem.

  • After I did a software update on my iPhone 5,once i emanble LTE,it loses Service/Network.What might be wrong?

    Hi,I ran a Software Update on my iPhone 5,but now if I "Enable LTE" it will display No Service and no network at all.What might be wrong here?

    It's completely situational. Without being able to directly compare the "scratch" on the original poster's iPhone with your iPhone, what gaamcc had happen could not be extrapolated to guess what Apple may do in your situation. It will depend entirely on what the Apple technician diagnoses after examining your iPhone. He/she may decide that any damage is strictly cosmetic and didn't have any connection with the problem you're taking your iPhone in for, or he/she may diagnose the problem as stemming from user damage. You'll just have to see when you go to the Apple Store.
    Regards.

  • Since ff13 update to ff13.1 my browser wont open and also wont open in safe mode and i tried to download ff13.0 but it wont open also. so i dont know what to do

    since ff13 update to ff13.1 my browser wont open and also wont open in safe mode and i tried to download ff13.0 but it wont open also. so i dont know what to do?

    here the other promblem

  • HT4718 i pressed shutdown button  and option alt and i wanted to delete everything now i dont know what to do

    i dont know what to do i pressed the shutdown and the` option button and i dont know what to do now

    See Here for  Frozen or unresponsive iPod touch
    Try this First... No Data will be Lost...
    Press and Hold the Sleep/Wake Button and the Home Button at the Same Time...
    Wait for the Apple logo to Appear...
    Usually takes about 15 - 20 Seconds... ( But can take Longer...)
    Release the Buttons...
    More Info here  >  https://discussions.apple.com/message/19521062

Maybe you are looking for

  • DB02 in ECC60 on V5R4 takes a lot of time to open!!!

    Hi Guys, We recently installed an ECC60 system(SR2) on V5R4M0. The installation went pretty well. We installed a double stack system with both ABAP+JAVA. After the install, did the post install including creation of my new clients and SGEN. Scheduled

  • After downloading itunes 10.6.1 dosent open on my PC windows XP

    After downloading Itunes 10.6.1 in my windows XP dosent open when i click agreen on the first page, that is the far i can go.... Thanks

  • Triple Display Issue with OSX Lion

    I have the following setup: iMac OSX (Snow Leopard) 3.06 GHz Intel Core i3 4GB 1333 MHz DDR3 500GB Hard Drive I have 3 monitors hooked up, one is a 24 inch benQ through mini display with vga and then i have the 21.5 imac and then a 23 inch acer hooke

  • Select mutilple values for variableprompt

    Hi, In obiee 11.1.1 I would like to know if i am creating a variable prompt with sql results and selecting user input as Choice List,and checking the Enable user to select mutilple values checkbox and also Require User input checkbox,Will i be able t

  • How do I get Lightroom to do nothing when I insert a memory card?

    I have changed the preferences under File Management to Do Nothing when memory card is detected, but still every time I put a memory card in it opens the program. Honestly if I can't get it to stop, I'm going to uninstall it and use Aperture. Second