/--[ Programming Styles Compared ]---------------------------------------------\
| |
-- [ K & R Style ] -------------------------------------------------------------
| |
| import java.util.*; |
| |
| public class Test {
| public static void main(String args[]) {
| int idx = 0;
| int tokenCount;
|
| String words[] = new String[100];
| String message = "This is some text that will be broken down";
|
| StringTokenizer st = new StringTokenizer(message);
| tokenCount = st.countTokens();
|
| System.out.println("Number of tokens = " + tokenCount);
|
| while (st.hasMoreTokens()) {
| words[idx] = st.nextToken();
| idx++;
| }
|
| for (idx = 0; idx < tokenCount; idx++) {
| System.out.println(words[idx]);
| }
| }
| }
|
-- [ BSD Style ] ---------------------------------------------------------------
| |
| import java.util.*; |
| |
| public class Test
| {
| public static void main(String args[])
| {
| int idx = 0;
| int tokenCount;
|
| String words[] = new String[100];
| String message = "This is some text that will be broken down";
|
| StringTokenizer st = new StringTokenizer(message);
| tokenCount = st.countTokens();
|
| System.out.println("Number of tokens = " + tokenCount);
|
| while (st.hasMoreTokens())
| {
| words[idx] = st.nextToken();
| idx++;
| }
|
| for (idx = 0; idx < tokenCount; idx++)
| {
| System.out.println(words[idx]);
| }
| }
| }
|
-- [ PHP Style ] ---------------------------------------------------------------
| |
| include('CONSTANTS.inc'); |
| include('mysql.class.php'); |
| if( $_SERVER['PHP_SELF'] == 'index.php' ) {
| require('header.php');
| } else { require_once('header2.php') }
|
| $wordsArray = array();
|
| function do_Stuff()
| {
| global $wordsArray;
|
| $str = "This is some text that will "
| . ' be broken down';
| $str_words_array = explode(",", $message);
| $numWordsString = count($str_words_array);
|
| ?>Number of tokens <?= $numWordsString ?><?php|
| foreach( $str_words_array as $word_key => $word_val )
| $words_array[$word_key] = $word_val;
|
| for($index2=0;$index2<$token_Count;$index2++) {
| $word_index = $index2;
|
| echo <<<EOT
| {$words_array[$word_index]};
| EOT;
| | }
| }
|
| do_Stuff();
| |
\---------------------------------------------[ http://www.killnine.com ]------/
/--[ comics ]------------------------------------------------------------------\
03.11.2008 - [0027] Celebrity Worship at the SXSW Interactive Conference
01.17.2008 - [0026] People who take themselves too seriously
03.30.2007 - [0025] A summary of Mark Zuckerberg's speech at Startup School
03.07.2007 - [0023] Who needs white strips?
03.07.2007 - [0022] Tiresome conversations
03.06.2007 - [0021] Dreamer
03.02.2007 - [0020] No one ever responds to my personal ads
03.01.2007 - [0019] Stop software abuse
02.28.2007 - [0018] Steve's Debris
02.27.2007 - [0017] Programming Styles Compared
02.26.2007 - [0016] What Would Jay-Z Do?
02.24.2007 - [0015] My brain is a dumb terminal
02.21.2007 - [0014] What if Camus were a Computer Scientist?
02.21.2007 - [0013] Memorization vs. Understanding
02.20.2007 - [0012] An elegant proof of determinism
02.20.2007 - [0011] A tribute to geeks
02.20.2007 - [0010] Getting p0wned by your girlfriend
02.19.2007 - [0009] I don't understand social networking
02.19.2007 - [0008] Don't judge a book by its cover
02.19.2007 - [0007] The day I tried to learn Spring and Hibernate
02.18.2007 - [0006] Sometimes I hate web standards evangelists
02.18.2007 - [0005] Last year I quit my job to become an online poker player
02.18.2007 - [0004] Graffiti in the math building
02.17.2007 - [0003] Every geek's fantasy: Meeting a girl in a wi-fi cafe
02.17.2007 - [0002] What happens when you think in terms of computer programs
02.17.2007 - [0001] It's hard to answer questions honestly at work in your 20's
\--[ rss ]-------------------------------[ killnine comics at gmail dot com ]--/