iv seen the line 'halt' in some pascal programs after readkey or readln. what does halt do exactly?

'Halt ' command = exit the main program :)

but cant you just use the command 'exit'? why are there 2 commands which do the same thing?

Halt = stop the main program
Exit = just going out from a block,if the main program is the only one block then 'exit' will accomplish the main program.

Don't forget "Break", to get out of a for i:=... loop.

how would one stop the main program in Java? Would you use the break statement?