A freight train has n railroad cars, each of which is going to be left at a dierent station. Assume
that the stations are numbered 0 through n

so: long story short, you posted your assignment here.
the best thing you can do, if you actually want to learn something about Java, is at least try. trial-error is a lot more efficient way to learn something compared to copy-paste. at least with trial error, you actually thought it through yourself.

The best way to continue now, is to try and implement it, piece by piece, and test it, piece by piece.then, if it doesn't work, and you don't know why: post your code and the part you're working on at that moment here, say why you believe this should work and what it should do. That gives us the opportunity to help you understand why it doesn't do what you expect. But, no, we won't do your homework for you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.