For the program I have the user entering their current distance and bearing from specified point with the programme then returning the nearest station and bearing/distance to this station.

However I also want to include what line the station is situated so I know the code will be something along then lines of

if (closest.name.equal("Wesston-On-Shore"));
return ("Docks Line")

not sure if this is correct plus how you 'name' it to recall in the display for the user any help would be appreciated

You could create a station class that stored the line (or lines) which it services. Depending on how your lines are managed you could either store its name in a string or a reference to the appropriate line class instance. Your calculation function could then determine which station is closest and return that string or reference.

A good rule of thumb is to separate your calculation and display code. This makes it much easier to write different GUIs and command line tools for your code if the need ever arises. It would probably work best to store a string for each station (either in an array or in a class, depending how complex your project is) and just print that string when you've determined the appropriate station.

if (closest.name.equal("Wesston-On-Shore"));
return ("Docks Line")

not sure if this is correct plus how you 'name' it to recall in the display for the user any help would be appreciated

well.. what is your method supposed to return, if anything?
a few mistakes in the above lines anyway:
don't put a ';' after your if statement itself:
there are 2 ways for an if statement to 'complete' it's conditional code:
1. the if statement is followed by brackets ({})
the conditional code runs untill the closing bracket of that block
2. if you don't use brackets, or you place your ';' on the wrong place: the conditional part of your if-structure ends as soon as the first ';' is found.
the return statement above will automatically execute, whether the if statement returns true or not.

also, if it's a String object you're returning, you could as easily code:
return "Docks line";
(and here you should place an ';' :) )

ok so I need to firstly

create a lines class, then create the if statement?

I think I understand what to do but am not 100% and yes it is a string i'm returning, well trying to, if anyone could give an example of the code I need so I can see it for myself it would be much appreciated

if anyone could give an example of the code I need so I can see it for myself it would be much appreciated

we're not really here to provide you with code, we're just helping you find and fix your bugs.

and I must say, it would be a lot easier to do so, if you explained exactly what this 'line' is that you're trying to return (what does it have to do, what does it represent ...) and the complete method you are working in, not just bits and pieces that leave information missing.

I've managed to solve my problem now I approached it differently and managed to create a solution to my problem thanks for the help guys

This question has already been answered. Start a new discussion instead.