Cole Schultz

Greenhorn
+ Follow
since Dec 10, 2011
Cole likes ...
Eclipse IDE Python Java
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Cole Schultz

Ok, cool. Thanks for the help
8 years ago
Another question: is it good/bad/proper to define all of your classes in separate .java files? I suppose it would depend on the situation, but if you only use a class in one particular program (like this example), is it better to define them separately or all together in one file?
8 years ago
Thanks very much for the insight! I'll have to remember to think in classes, although it doesn't come naturally to me. I suppose I'll just have to get used to it.
8 years ago
Thanks

Also, does anybody have any comments on the code? Did I do it right?

Also, why is it that the checkString function has to be static? I've seen other programs where there are functions outside of main() which aren't static, but java throws an error if checkString isn't static.
8 years ago
Sure! the error is this:


Edit:
Oh, silly me. I shoulda just looked up the error, but I must have been too tired to realize that the error message wasn't nearly as vague as I thought it was. I've figured out now that the Eclipse console doesn't count as a console, and so c was being assigned to a null. If I compile with javac it works fine
8 years ago
Hello everyone!

I'm extremely new to Java, so bear with me, eh?

Next semester in my computer science class we're going to learn Java. Being a relatively experienced programmer (in Python mostly, but a teeny tiny bit of C as well), I decided yesterday that I should learn Java so I could be a bit ahead of the curve.

After having read through most of the basics of Java in the Java tutorial, I thought it'd be a good idea to search for some simple challenges to complete to make sure I had it down. After a bit of searching, I found a post on this forum about another person who was given the task of writing a program that could determine if one string was a substring of another. I thought this would be a cool challenge, so I decided to code it. For the most part it works - I think the general algorithm is solid - however when I try to make it so the user can specify the string through console input, it throws an error at me, which I can't decipher.

So my question is, how do I properly get user input from the console?

Also, I have no idea if this code is "proper" Java.

Here's the code:


If you have any suggestions for any of the code, they're greatly appreciated!
8 years ago