Can anyone help me how to print a String in console without using System.out.println() in java?
Why do you not want to use System.out.println? Is this an interview question or a school test? Are there other constraints?
I would suggest looking at the docs for the System class and the PrintStream class to start with.
This is an interview question thats why i am asking this question. Whatever you mentioned that is also not correct way to print the String without using System.out.println(). Without using print related method but i want to print any statement. I am not telling you that i am not using this System.out.println(); i am using this but i want to know that is there any other code available which can print the statement without using System.out.println() method.
Personally I think it's a ridiculous question. There is no one right answer, and it has no real-world applicability whatsoever. The interviewer may have thought he was being clever and trying to get you to think outside the box, but this question doesn't really test that at all. And I bet he's looking for one specific answer, and there's no way you could know that without knowing what constraints and assumptions he has in mind.
If answering this question correctly helps somebody get a job, I don't want to read that person's code, or use that company's products.
Jeff Verdegan wrote: If answering this question correctly helps somebody get a job, I don't want to read that person's code, or use that company's products.
Just another example that very Tom, dick and Harry gets to be the interviewer in India's IT industry. Even people who think that they are smart when, in reality , it is quite the opposite. That is one thing I have learned about taking interviews - Never take it for granted that the interviewer will be better than you at what he's supposed to test you for. Many a times they are. But on and off I keep on encountering fools.