Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My problem is that in string.format i cant get my string to use a new line with "\n"
all the ab's are double .

String reciept = String.format("Recipt number #16424 +"  + "%n" + "Beef Burgers :" + ab1 +"%n" + "Cheese Burgers :" + ab2 + "%n" +   "Fish and Chips :" + ab3 + "%n"  + "French Fries :" + ab5 + "%n" +  "Steak :" + ab4 + "%n"  + "Sprite Drinks : " + ab + "%n" +  "Soda Drinks : " + ab8 + "%n" + "Fuzetea Drinks : " + ab7 + "%n" + "Coke Drinks :" + ab6 + "%n" , ab,ab1,ab2,ab3,ab4,ab5,ab6,ab7,ab8);
            recieptText.setText(reciept);


What I have tried:

have tried with "\n , /n %n" Dunno what to do
Posted
Comments
Mohibur Rashid 12-Sep-18 17:57pm    
everything you have done here is wrong. there is no %n..
Follow this link
https://dzone.com/articles/java-string-format-examples
Richard MacCutchan 13-Sep-18 3:52am    
In Java string.format %n is accepted as the newline indicator. Also shown in your link.
phil.o 12-Sep-18 20:07pm    
What is the point using string.Format if you do string concatenations anyway?
I think you did not understand at all the usage of the Format method; you should have a look at the link Mr Rashid provided you in his comment.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900