i use vim in the terminal. TextMate is great, and I know a lot of people who swear by Smultron which is no longer updated but runs fine on 10.5 and previous.
Wow I feel retarded. I spent 2 hours looking for the Java 6 SE SDK to download to my macbook, only to find out that it came pre-installed with OS X. So all I should need now is some kind of IDE right? I just got my Macbook last term so I'm still trying to make the switch. My teacher wants us to use Textpad which unfortunately is only Windows compatible. Textmate looks pretty sweet though, thanks guys.
If you want to go with a full blown IDE, Netbeans ( <a class="postlink" href="http://netbeans.org/" onclick="window.open(this.href);return false;">http://netbeans.org/</a> ) is fairly solid on mac, but as he'd likely prefer you using a straight text editor you should just use Smultron/TextMate/whatever and use the command line tools to compile your programs.
My decent into madness with Java continues. The textbook for my class is a steaming pile of dookie. NONE of the code examples have the import statements (public class, void, import, etc), the second chapter skips straight to Applets without giving any clue how to compile into HTML code. Hell half the programs on the CD won't even run. The pile of crap is JAVA Software Solutions foundations of program design 6th ed by Lewis and Loftus. Without a doubt the worst textbook on anything I've ever encountered. Now I get to drop some more cash on the books mentioned in this thread.
Is it possible to create and run Java applets on Textmate ? I'm trying one right now and its trying to run it as an application so I'm getting the "main method" error.
No. The option is (for testing) to include a Main method that instantiates and runs the applet you're working on. The applet container (browser, etc) does this for you. It's only a few lines of code, and makes writing/debugging the applet a hell of a lot easier. Or, use a proper IDE (like Idea, or Oracle's free JDeveloper) that will properly package and deploy the applet for you to a server that you can then launch in a browser.
I got my bachelors in Computer Science from University of Michigan, where almost all of the courses are in C++. I haven't really written anything in a text based language since I graduated last spring. I'm trying to get my ass in gear writing apps on the iphone (Objective C) but I'm finding it really hard to get motivated. In school I also used C and Java enough to know my way around. Since graduation I've been programming with LabVIEW for my job, so I'm sure I will be really rusty when I finally get going on my iphone projects.
If you've already got experience programming with Java, you could look into developing for Android-- that's all Java.
Hey guys I'm getting an illegal start of expression error on my toString method. I have no idea why, it's not inside another method etc. I'm sure it's something moronic that I'm missing but any help would be appreciated.
you forgot your semi-colon after the return pet statement. you may want to add some spaces to the string also, because what you have right now will return- "NamePepperAge3" When I'm guessing you want something similar to this "Name- Pepper, Age- 3"
It's been a while since I've done text programming, but isn't that last + he has in there going to be trouble? String pet = ("Name"+ Name + "Age"+ Years +) ;
Yeah I fixed the ; and the + so that's running fine now. Unfortunately my main file refuses to compile. All I'm supposed to be doing here is multiplying the dog's age by seven. Thanks a lot for helping me with this stuff guys. I'm pretty lost right now with this class.
Sethumanyears is a method. You're trying to access it as you would a public member (instance variable) of the class. Moreover, it takes an arguments, so to call it, it would look like: Code: dog1.Sethumanyears(3) Is there a reason you're not working with Eclipse, or any of the other freely available Java IDEs (mentioned earlier in this thread)? They would have made catching this error much easier. Also, learn about conventions. There's a way people usually write code in Java (when it comes to, at the very least, capitalization of names of members and methods, and it will make your code a lot easier to read.
NVM fixed it. turns out I was missing a set of quotations parentheses after dog1.DogYears Anyone care to explain why it needs to be there?
In future, cut/paste the error you're getting in here if you want help. Your interpretation of those errors is usually crap, especially if you can't figure it out yourself. If you're not getting detailed error output, you're doing it wrong.
Here's a little background on my problem: I'm working on a java program that implements redistricting algorithms. It's pretty simple but if you don't understand what it is, wikipedia: http://en.wikipedia.org/wiki/Redistricting has a good explanation. (Note, you don't actually need to understand redistricting to help me with this problem). The code works through three stages: the first two stages are complete. They form the initial districts by merging individual blocks (the individual units each containing population data), make sure the formed district is contiguous so you won't have parts of districts unconnected with each other, and that no blocks are unassigned. Unfortunately, you want all your districts within a state to have an equal amount of population and the first two stages don't take into account population densities. That's what the third stage is for, assuring population equality within all the districts, at least within acceptable parameters. My initial algorithm has the code checking all the districts and looking for any that are under or over populated. Then it looks at those district's neighbors and see if the district and its neighbors can swap blocks as long as the swapping won't make the neighbor under or over populated. This part works. My problem now is when all the neighbors are at the threshold meaning that any swapping of blocks with the under/over populated district would push the neighbor past acceptable limits. I was thinking of having the neighbor check with ITS neighbors and seeing if they can swap. If they can't, then I would have the neighbor's neighbors check with their neighbors and see if they can swap. The code would continue recursively if the answer is no. I'm not sure if this would work and am kind of hesitant to implement it without first checking to see if its viable. My adviser simply said that using recursion with such large data samples (I'm working with the data of entire states) is unfeasible for computers to run. However, though the sample space contains tens of thousands of blocks, my proposed algorithm would only be looking at districts, of which there would be at most a few dozen. I'm not a CS major so I'm unfamiliar with the theory behind feasible run times. In fact, I'm learning about Java as I go. Would the run time with recursion still be prohibitive in this instance? Does anyone have advice on how I could implement my algorithm through a while loop or some other method besides recursion or do you think recursion is feasible?
Really, it all comes down to what the data looks like that you're working with, I think. I've read this over a dozen times, and am still somewhat unclear on the issue. I've done this kind of thing (kind of) before, but that was using geo-spatial aware and tagged data sets, and utilizing built-in functionality within the database to do all the heavy lifting. Also, this kind of thing sounds like the perfect candidate for something like MapReduce. If you're seriously trying to find the solution to the problem, consider grabbing a few hundred Amazon EC2 nodes (that whole cloud computing thing), and Map Reduce the fuck out of the problem/data set. You'll get an answer in a few minutes, and it'll cost you a few bucks. I've done this in the past where I've spun up a couple hundred MapReduce nodes in EC2 to process and analyze telemetry data for some data warehousing/reporting analysis. Took a single-box process that took 18 hours to something that took 8 minutes. And cost us $15 or so. Are you looking for the real answer, or trying to figure out a comp sci algorithm? What's the goal here?
EDIT: Fuck, sorry for old reply, read the date wrong. Hope that helps someone, anyway. I've never done anything with redistricting algorithms (nor did I read the Wikipedia link), but your process seems flawed. Let me know if I'm missing something in your explanation, but: Why is this a three step process? If you gave me a map with populations on it and told me to draw even districts, I'd total the populations, find a multiple, and then make districts. Your process seems to me that I'm drawing what I imagine would look nice, then trying to tweak it into place. The most efficient algorithm for stages 1,2 is to lump everything into one district anyway, correct? That meets both criteria you mentioned (all connected/no unassigned). I'd suggest you figure district bounds (size, population) and then merge units following that template. By sorting the individual units by location, running the list will create connected and fully assigned blocks. I've done similar algorithms to lay out gameboards before and the biggest problem is top-heavy beginnings or endings, but that is less of an issue with better bounding criteria. As to your specific questions, that recursion is not a big deal. Your algorithm (should) only look at one district at a time, and the recursion will only include branch information (OK or NO, next check). Loop looks like (psuedocode): Code: // variable names should be self-explanatory loop while ( currentDistrict != NULL ) { // where NULL is end of map if ( currentDistrict[population] < topBoundary-neededSpace ) { makeSwap(branch); end loop; } elseif ( currentDistrict[population] < topBoundary ) { availableSpace = topBoundary - currentDistrict[population]; neededSpace -= availableSpace; branch[] = Array ( currentDistrictPointer, availableSpace, OK ); } else { branch[] = Array ( currentDistrictPointer, 0, NO ); } // method for following branch depends upon how you handle district creation // assuming you already know how to access bordering districts currentDistrict = next; } // loop logic above isn't good, but should illustrate the point Looping and sorting data is precisely what computers are good for -- like Nettdata said, even with absurd datasets shared computing works wonders (see SETI, the protein thing, crypto sites). Don't paralyze yourself with preemptive optimization; if it works it works, if not, THEN you can tweak your method. (you get better at design with practice, but sometimes you just need to know if the idea works) HTH