Results 1 to 8 of 8
  1. #1
    earnest is offline Member
    Join Date
    Feb 2011
    Posts
    9
    Rep Power
    0

    Default Need help declaring array

    Hi Guys, please help
    How to i declare the following in array

    0. car min height = 5 max height = 4 cost = 10
    1. var min height = 3 max height = 7 cost = 11
    2. truck min height = 3 max height = 6 cost = 12
    3. cancel

  2. #2
    dinosoep is offline Senior Member
    Join Date
    Nov 2009
    Posts
    150
    Rep Power
    6

    Default

    what have you tried so far?

  3. #3
    earnest is offline Member
    Join Date
    Feb 2011
    Posts
    9
    Rep Power
    0

    Default

    This is what i have so far

    String weapons [] = new String [4];
    weapons [0] = Bat MinDmg = 2, MaxDmg = 4, cost = 3;

    I am lost

  4. #4
    earnest is offline Member
    Join Date
    Feb 2011
    Posts
    9
    Rep Power
    0

    Default

    sorry, this is what i have

    String vehicle [] = new String [4];
    vehicle [0] = car minHeight = 5, maxHeight = 4, cost = 10;

  5. #5
    dinosoep is offline Senior Member
    Join Date
    Nov 2009
    Posts
    150
    Rep Power
    6

    Default

    weapons? in the start post you were talking about cars...
    read this:
    Java arrays - Java tutorial

  6. #6
    earnest is offline Member
    Join Date
    Feb 2011
    Posts
    9
    Rep Power
    0

    Default

    thank you. i did but can seem to get a grasp of it. give me a quick answer of explanation. will be grateful

  7. #7
    earnest is offline Member
    Join Date
    Feb 2011
    Posts
    9
    Rep Power
    0

    Default

    I want i am doing does not work. Please help

  8. #8
    kbro3 is offline Member
    Join Date
    Feb 2011
    Posts
    24
    Rep Power
    0

    Default

    Hey mate,

    If you're wanting to store "weapons" in an array, you should make a weapons class, and then store weapons objects in an array. (Array of type weapon. For instance, right now you're trying to store them in a string array).

    Cheers,

    Kirill

Similar Threads

  1. Declaring a long
    By gbtimmon in forum New To Java
    Replies: 3
    Last Post: 01-13-2011, 07:20 PM
  2. declaring classes
    By coltragon in forum New To Java
    Replies: 17
    Last Post: 12-21-2009, 07:20 PM
  3. Declaring a Queue
    By rhm54 in forum New To Java
    Replies: 1
    Last Post: 03-21-2008, 06:02 AM
  4. Declaring Interface
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-08-2007, 09:41 AM
  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
  •