Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

HOW TO PRINT 'HELLO WORLD' WITH OUT ' ; '(SEMI COLON) IN JAVA AS WELL AS IN C

  Asked By: Chisisi    Date: Sep 24    Category: Java    Views: 5880
  

HOW TO PRINT 'HELLO WORLD' WITH OUT ' ; '(SEMI COLON) IN JAVA AS WELL AS IN C

Share: 

 

7 Answers Found

 
Answer #1    Answered By: Samuel Costa     Answered On: Sep 24

put it in if expression....................

 
Answer #2    Answered By: Dirck Jansen     Answered On: Sep 24

Don't quite understand, How to print  HELLO WORLD
witout the semicolon...What semicolon? You mean
something like this:
......
System.out.println('HELLO WORLD');
|
without this semicolon

 
Answer #3    Answered By: Calais Bernard     Answered On: Sep 24

exactly that wat he means..

do this

public static void main(String args[]) {

if(SOP_HERE)........
}

 
Answer #4    Answered By: Calvin Banks     Answered On: Sep 24

But what's the point?
I think the semicolon in a print  statement is like the
RED LIGHT for the string, please correct me if I am
wrong.

 
Answer #5    Answered By: Ralph Murray     Answered On: Sep 24

Unfortunately it's not as easy in Java as in C/C++. In C and C++ the
function printf() always returns an integer indicating how many
characters have been printed; System.out.print() and related functions
in Java are void functions, so they can't be used in an if statement
like mentioned by Anurag.

I think it might be able by using some Stream output function instead
of System.out.println(), but you should check the Javadoc of streams
whether this is possible or not. To be honest I'm not in the mood to
look this up myself, I'm on vacation. ;-)

The C version might be this one, I haven't tried it yet:

int main( int argc, char * argv [])
{ if (printf( "Hello world!\n"))
{}
}

 
Answer #6    Answered By: Radhakrishna Gudimetla     Answered On: Jan 31

yes,
i found this answer to this tipical question in java.



take this and enjoy it.........................................


for(int i=0; i<1; System.out.println("Hello World!"),i++);

or

for(int i=0; i<1; System.out.println("Hello World!"),i++)
{

}


 
Answer #7    Answered By: Suraj Ghimire     Answered On: Jan 03

Hi Friends its pretty easy,
see the link www.nataraz.in/.../

 




Tagged: