Showing posts with label java strings. Show all posts
Showing posts with label java strings. Show all posts

Sunday, 18 December 2011

Java: String Formatting (Pictures!) and the Switch Statement

Okay so, apparently no pictures is a huge no-no, so I'll briefly show you how string formatting works with the power of screenshots! And yeah, looking back on yesterday's post, I agree, it was kinda shitty, so, sorry about that :P

So, string formatting! First, we need to formulate a template string in which data will be entered later!

Saturday, 17 December 2011

Java: String Formatting

First off: To Damian in the comments: The game could kick the player when its discovered they're broke, but that's not up to the player class! It's up to either the Table or the ConsoleClient!

Okay! Short post today, just covering string formatting. We saw in some code there was a string returned that looked roughly like:

"This is the message, %s, %f"


...within a method that took 2 more parameters. When printed out this way, the first parameter, the string, is the format of the message to be printed out. A percentage sign followed by a letter denotes where you'll want to put data in afterwards.