Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.37 KB | None | 0 0
  1. public class test
  2. {
  3.  
  4.     public static void main(String[] args)
  5.     {
  6.         String s = "123-abc";
  7.         int length = s.length();
  8.  
  9.         if (length == 7 && (s.charAt(3) == '-'))
  10.         {
  11.             System.out.println("Correctly formatted string");
  12.         }
  13.         else
  14.         {
  15.             System.out.println("Malformatted string");
  16.         }
  17.  
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement