Bobby Smallman

Ranch Hand
+ Follow
since Sep 09, 2010
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Bobby Smallman

Welcome to the Ranch Tim! Dennis's code is exactly right. As a suggestion to you to help you more quickly find answers to your problems, for questions such as this it is probably easier on you to just use Google to find a solution. For example, searching for "Array to ArrayList Java" brings up this exact same code instantly.

We all appreciate questions and they also provide new resources for people to find on Google when searching, but I know from personal experience that it can often times be faster for these smaller questions to just type exactly what you want into Google, even though Dennis was extremely fast in answering!

12 years ago
Have you double checked that the Dob string is actually set when you are forming the query string? Perhaps you are having a problem prior to the query since you have tested the same query with manually entered data.
13 years ago
JSF
Good work at solving your own problem! In my opinion it is always more satisfying and helps you more in the long term when you work your way through your own problems.

Just a quick comment however, if you want quick and meaningful responses to your posts it is vital that you give a little more information, specifically some code. It is often times difficult for anyone to respond with any value without more to go on. I would always post whatever code you have thus far that you are trying to make work. Good luck to you and good job again at figuring out your own problem!
13 years ago
Where exactly are you trying to access the file from? Windows Vista and 7 get angry if a program who is not explicitly run "as Administrator" is trying to access/modify files outside of area where Windows thinks it should be meddling. For example, Windows Vista and 7 likes to restrict all access to files within "Program Files" unless the program has direct coloration to the folders in question (or again explicit administrator access, by which I mean when you are directly prompted to click "Yes" or "I Agree" to access a file/folder in the wonderful Windows pop-ups) If you have not already done so, I would place the file you need access to in a public location such as you "Documents" folder or directly in your workspace for Eclipse. Let us know where exactly your file which needs to be accessed is located and also if the user which you are logged in as has full rights on the system.
13 years ago
Congratulations on passing the exam, and thank you for supplying your feedback about your experience! Always helpful to everyone here at the Ranch!
Welcome to the Ranch Cheryl!

It seems Tom has your answers all cleared up rather nicely but I just wanted to comment on something which is almost off-topic. I read Java forums a lot, and I must say I really appreciated how you setup your question. You wanted a breakdown line by line, so you commented in concise and specific questions directly with your code in question. I hope more people catch on to your thoughtful approach, seems like half the posters in this section don't even post with code tags! Keep up the good work and once again, welcome to the Ranch!
13 years ago
My bad At least I can be comforted by the knowledge that if that wonderfully intelligent/moral/scrupulous/Java loving/Insert other sarcastic adjectives here, did just copy/paste. He will be stuck with terribly weak code and no understanding of what should have been their goal of the thread. Won't happen again guys!
13 years ago

Campbell Ritchie wrote:

Bobby Smallman wrote:. . . A simple yet efficient way . . .

The Sieve is hardly more complicated, and much more efficient; that code will run in quadratic time and looks inefficient to me.

I suspect the Sieve is quadratic complexity, too, but still much faster.



The Sieve is absolutely a significantly more efficient way to go. After already suggesting they research the Sieve further and read through a past post which showed the general outline of the Sieve and some pitfalls/optimizations which are helpful there was a comment that it was complex and to keep it simple. The method in my last post is an implementation of a non-Sieve method of finding prime numbers, I posted it as a stepping stone in their logic, because it is closer to their current code, to help them build a foundation in that sort of logic in order to ultimately be able to revisit their research in the Sieve.

With that being said, hopefully it is clear to the original poster that the Sieve of Eratosthenes make prime finding happy.
13 years ago
Since it sounds like you want to avoid more complex code like the Sieve. A simple yet efficient way to do it is something along the lines of this



And if your end goal was providing a list of prime numbers and not just determining if a number was prime, you can clearly use that isPrime method that way as well. I got in the habit of breaking out small chunks of code like this for Project Euler.



The Sieve can speed things up but as you have pointed out it can be overwhelming when you are new to thinking about this kind of logic. It is important to note in the isPrime method there that it only goes to the sqrt of the number looking for divisors. That is a significant speed increase at least over iterating all the way through the number.
13 years ago
You will be interested in reading through this past forum thread as well.

https://coderanch.com/t/516856/java/java/Sieve-Eratosthenes#2343984
13 years ago
Extending multiple classes was primarily left out in order to keep Java "simple." The main problem which programmers could encounter with being able to extend multiple classes is the Diamond Problem (which I prefer to call the Dastardly Diamond of Death) When extending multiple classes it creates a serious possibility of ambiguity in your method calls/classes. The reason why multiple interfaces are allowed to be implemented is that you must override all methods provided by the interfaces you are implementing. While you can still have odd naming problems with multiple interfaces the forced override of all methods in the implementing class helps to limit all the pitfalls of extending multiple classes.

There was an old entertaining article about interfaces and why Java developers decided to go the route the did, I will edit my post if I come across it again.
13 years ago
When in doubt, check the API. Not only will it help you become to have a better understanding of Java but going through the API yourself is definitely faster than waiting for responses on a forum (even if the Ranch has incredibly fast responses!). Good luck to you!
13 years ago
public static void = a static method which allows public access and returns nothing. This means it is available for anyone to see/use because it is public, it is associated with the class not an instance because it is static, and void always simply means there is no return value for the method.

public void = a non-static method which allows public access and again returns nothing. This means it is available to anyone just as above, but this time because it is not static it is associated with an instance not the class itself. Again because of the void there is no return type.

public 'returnType' = a public method which is showing you that where "returnType" is you may place whatever it is your would like your method to return. If you want it to return a string a method would look like


or if you wanted to return an Integer


Generally it is a good practice to search for the information on your own first prior to posting as each of these come up with tons of information if Googled. Also check out the link in marc's post. Welcome to the Ranch!
13 years ago


Head First Java is the best Book for Java Beginners- Lot of us have used that book and benefited from its style of presentation. Also you can check out the BunkHouse-Beginning Java for other books reviewed by JavaRanch.



Seconded. Head First Java is a great starting place for Java Beginners.
13 years ago