Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Java Printing Question : Multiple characters through mathematical operations?
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
fastftw




PostPosted: Sat Nov 03, 2012 11:14 am   Post subject: Java Printing Question : Multiple characters through mathematical operations?

I was looking at some python code and you can print characters multiple times through multiplication in a print statement. Example:

out.write("*"*d)

I was wondering if there is an equivalent in java? Something that would imitate

System.out.println("*"*3);

which would output:

***

Thanks a bunch!
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Sat Nov 03, 2012 6:02 pm   Post subject: RE:Java Printing Question : Multiple characters through mathematical operations?

Not as far as I know. Just use a for loop. There might be a string operation that does this (which is independent from the output stream) but I doubt it.
DemonWasp




PostPosted: Sun Nov 04, 2012 2:50 pm   Post subject: RE:Java Printing Question : Multiple characters through mathematical operations?

There's no standard multiplication operation for Strings. The only overloaded operator in Java is string+string, which works for concatenation.

You could write your own, but it wouldn't be as concise, which is fairly common in Java.
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: