John de Michele

Rancher
+ Follow
since Mar 09, 2009
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
5
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by John de Michele

Faisal,

It looks like the original author is just demonstrating throwing exceptions. From the code you posted, you could replace IllegalStateException with another one, and get the same meaning.

John.
7 years ago
Kevin,

As Stephan pointed out, Java does not recognize any sort of package hierarchy. Conceptually, they are frequently used that way in the real world, but Java itself doesn't care.

John.
7 years ago
Daniel:

Another niggly style issue: member variable names should be in Camel Case, starting with a lowercase letter. Underscores between words should be avoided, unless you're doing a static final in all uppercase.

John.
7 years ago
Ashish:

O'Reilly has a book titled Algorithms in a Nutshell which I found to be useful. Also, there's an older book titled Algorithms in C++ which I found to be valuable. The code examples in it are very simple, so you should have no problem adapting them to Java.

John.
7 years ago
Daniel:

A few things:

1. Java classes start with capitals, so the class should be ReadJson, not readJson.
2. You can't have code outside of a method (hint: see line 10 of your erroring class)
3. Classes don't throw exceptions, methods do.

John.
7 years ago
Ashish:

Read up on algorithms and Java best practices. Take some programming classes. Keep coding.

John.
7 years ago
Faisal,

Threading is a complex subject, and you really can't learn it well just from doing a tutorial. I suggest you pick up a copy of Java Concurrency in Practice by Goetz, et al.. It's one of the best books out there on the subject.

John.
7 years ago
Ryan:

Did you check the values of the chars being returned? A bunch of '?'s suggests that you're returning control characters.

John.
7 years ago
Kevin:

Because generics in Java don't work that way. You can't assign an array of EnumMap<T, U> to an array of Map<T, U>.

John.
7 years ago
Ankit:

Googling 'java io outputstream tutorial' will give you several examples.

John.
7 years ago
Faisal:

Strings aren't wrapped. If you look at the JavaDoc for Integer.valueOf(String s), you'll see that it's quite clear that if the String doesn't represent an integer value, you'll see the NumberFormatException you got. If you want to convert a String representing a floating point number, you'll have to add an intermediate step.

John.
7 years ago
Craig:

Definitely start small. I know there is a temptation to do a few code examples and feel like you can code a huge project. Avoid this temptation like the plague. You'll end up frustrated, or worse, you'll give up on programming. The fact that you're asking this question is good, but it illustrates how far you have to go. My suggestion would be to find a small project that interests you, and work on it until you complete it. Maybe it'll be a card game, or a text-based RSS reader. Once you've gotten a few, smaller projects under your belt, then is the time to attempt to tackle something bigger.

John.
7 years ago
Palanisamy:

The problem with reading large files whole into memory is exactly what you describe - you run out of memory, it's horribly inefficient, wastes resources, etc.. If that five line XML pattern is consistent, then what you probably want to do is check for the first line, and if that matches, check to see if the next four lines match. That way, your file can be 1MB, or 1GB, or 1TB, and you don't have the problem of accidentally splitting files in the middle of the pattern you're looking for.

John.
7 years ago
Sunny,

Ok, I think I see the problem, and it doesn't really have anything to do with JUnit 4, Eclipse, or Selenium. You're mixing your page classes and your tests. You probably want to set your test up similar to this layout:



In general, I prefer to separate concerns by having a set of page objects that know their behavior, and use a single Selenium object, and having a set of tests that only use the page classes' interfaces. Also, since you are using Eclipse, you don't need to create a test suite, as Eclipse has a JUnit 4 test runner that will run your test and give you graphical output.

John.
7 years ago
Palanisamy:

That is almost certainly the wrong way to go about it. What precisely are you searching for, and what have you tried so far?

John.
7 years ago