Skip to content

Instantly share code, notes, and snippets.

@0x000000AC
Created November 30, 2012 22:35
Show Gist options
  • Save 0x000000AC/4179197 to your computer and use it in GitHub Desktop.
Save 0x000000AC/4179197 to your computer and use it in GitHub Desktop.
This program show swhat happens when you call the length method with strings of different lengths
/***********************************************
* LengthMethod.java
* Aaron P. Clark
*
* This program shows what happens when you call the length method with strings of different lenths.
***********************************************/
public class LengthMethod
{
public static void main(String[] args)
{
String s1 = "hi";
String s2 = "";
System.out.println("number of characters in s1 = " + s1.length());
System.out.println("number of characters in s2 = " + s2.length());
} // end main
} // end class TestExpressions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment