Jump to content

Super newb question

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
Slick

Slick

    Newbie

  • Members
  • Pip
  • 5 posts
Hi, first off just want to say if there is a better place to ask really newb kinds of questions, please direct me there and I'll gladly go there. Didn't see any such subforum.

I've been on and off messing with programming for years, never could get full head into it, but trying now, maybe it is because my peers are quite the typical "lololol computer nerd!" kind of people. Maybe joining a good forum/community will help with that.

Anyway, now that I've wasted time babbling... I picked up a Sams Teach Yourself Java in 24 Hours book. I like its flow but I am having an issue with one of their little "try it outs."

First hours of the book, kiddy stuff:

class BlankFiller {

    public static void main(String[] args) {

        System.out.println("The " + args[0]

                + " " + args[1] + " fox "

                + "jumped over the "

                + args[2] + " dog."

                );

    }

}

I am using NetBeans. I did what it said and tried running it without adding the arguments to get the error. However, after setting project configuration with main class as BlankFiller and adding the three arguments, I still get

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0

        at BlankFiller.main(BlankFiller.java:3)

Java Result: 1

so basically... ????

BTW I did take an intro C++ class a couple years ago, and it was a joke, doing quite a bit more complicated stuff than this, so I kinda know what I am doing right now, as far as glaringly obvious mistakes go anyway. Thanks for your time

#2
Slick

Slick

    Newbie

  • Members
  • Pip
  • 5 posts
Well, figured it out. The book says to do run file but you need to do run main project. I am going to guess that either there was an error in the book or a change in NetBeans since it was published. Perhaps just doing run file only runs the actual file and doesnt gather the arguments so you need to run the "whole thing" ie main project.