Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Unlimited Args as Param
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Prince Pwn




PostPosted: Tue Mar 09, 2010 2:20 pm   Post subject: Unlimited Args as Param

Why does the following code work in Netbeans and not in RTP. Only difference I know is RTP uses Java 1.4.x and Netbeans uses a later Java version. When I F2 indent in RTP, the dots in the param and colin in the for mis-allign.

Java:

public static void main(String[] args) {

        System.out.println(average(10,40,50));


    }


     public static double average (double... numbers)
        {
            double total = 0;
            for (double d: numbers)
                total += d;
            total /= numbers.length;
            return total;
        }
Sponsor
Sponsor
Sponsor
sponsor
chrisbrown




PostPosted: Tue Mar 09, 2010 3:12 pm   Post subject: RE:Unlimited Args as Param

Variable-length parameters were introduced in verson 1.5 (aka Java 5). Stop using RTP, its a waste of time.
Prince Pwn




PostPosted: Thu Mar 11, 2010 5:00 pm   Post subject: Re: RE:Unlimited Args as Param

methodoxx @ Tue Mar 09, 2010 3:12 pm wrote:
Variable-length parameters were introduced in verson 1.5 (aka Java 5). Stop using RTP, its a waste of time.


Name one other IDE that compiles and executes on the fly, auto-indentation, syntax highlighting and I'm sold. NetBeans = slow, JCreator = slow, Notepad & cmd = slow.
Insectoid




PostPosted: Thu Mar 11, 2010 5:46 pm   Post subject: RE:Unlimited Args as Param

RTP is version locked (stuck on 1.4 permanently) while other IDEs are just that, IDEs. Developing environments that update with the language (in fact, you can update the language without changing the IDE at all).

Quote:
cmd = slow.


This is an outright lie. The command line is damn fast, faster in fact than any IDE. IDEs have GUIs bogging them down and do exactly the same thing, but invisibly or with restricted compiler output. I compile everything from the command line, because it's faster and because it makes me look 1337. Hell, my IDE is just a text editor with syntax highlighting.
chrisbrown




PostPosted: Thu Mar 11, 2010 6:34 pm   Post subject: Re: RE:Unlimited Args as Param

Prince Pwn @ Thu Mar 11, 2010 5:00 pm wrote:
Name one other IDE that compiles and executes on the fly, auto-indentation, syntax highlighting and I'm sold.


Eclipse.
facultyofmusic




PostPosted: Fri Mar 12, 2010 5:48 pm   Post subject: Re: Unlimited Args as Param

you can always make a batch file or just make a java program that compiles and runs it for you. Then notepad won't be so bad. I personally prefer netbeans, except it's more like project based =(
TheGuardian001




PostPosted: Fri Mar 12, 2010 6:31 pm   Post subject: Re: RE:Unlimited Args as Param

Insectoid @ Thu Mar 11, 2010 5:46 pm wrote:

Quote:
cmd = slow.


This is an outright lie.


I think they probably meant in terms of actually setting it up to compile, not compile times. Also generally not true, but it makes a bit more sense.

OT, I'd also recommend Eclipse. It's the best I've used so far.
Insectoid




PostPosted: Fri Mar 12, 2010 6:39 pm   Post subject: RE:Unlimited Args as Param

I admit, it's a bitch to get the command line working the first time on Windows, but once you've figured it out it's very quick to update or add compilers and interpreters.

OS X has them in developer tools. One install comes with Ruby, Python, Java, C++ and more compilers and interpreters. The actual usage, depending on how you've formatted the file, is 'ruby myfile' or 'g++ myfile' If you adjust the permissions you can run the file with a double-click (I dunno if this works for compiled languages, you prolly need a binary).
Sponsor
Sponsor
Sponsor
sponsor
chrisbrown




PostPosted: Fri Mar 12, 2010 6:45 pm   Post subject: RE:Unlimited Args as Param

Unless I'm misinterpreting, if you're using g++ in that way, then it does indeed work with compiled languages.
Prince Pwn




PostPosted: Sat Mar 20, 2010 5:40 pm   Post subject: Re: Unlimited Args as Param

facultyofmusic wrote:

you can always make a batch file or just make a java program that compiles and runs it for you. Then notepad won't be so bad. I personally prefer netbeans, except it's more like project based =(

I've done that Very Happy

Insectoid wrote:

Prince Pwn wrote:
cmd = slow.

This is an outright lie.

You still type your code, ctrl+s, alt+tab, inside cmd do UP ARROW then hit return and even then it takes 1 second + to compile on a quad, then finally you alt+tab back to your code.
Whereas F1 executes and compiles on the fly on the same system. No clue why but using an IDE somehow compiles faster than the cmd!
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 10 Posts ]
Jump to:   


Style:  
Search: