-- Leo's gemini proxy
-- Connecting to republic.circumlunar.space:1965...
-- Connected
-- Sending request
-- Meta line: 20 text/gemini
Can you guess the output of this program?
class SplitTest { static void split( String s ) { System.out.println( s.split( ";" ).length ); } public static void main( String[] args ) { split(""); split(";"); split("x;"); split(";y"); } }
Here it is:
$ javac SplitTest.java && java SplitTest 1 0 1 2
Wow. Docs: String.split.
Side note: It's not easy to fit Java examples into tweets.
>
>
>
> class X{static void x(String
> s){System.out.println(s.split(";").length);}public static void
> main(String[]a){x("");x(";");x("x;");x(";y");}}
>
> — Andy Balaam (@andybalaam) May 23, 2013
Originally posted at 2013-05-23 12:51:52+00:00. Automatically generated from the original post : apologies for the errors introduced.
-- Response ended
-- Page fetched on Sun May 19 06:12:24 2024