/* Copyright (c) SEMM NL All rights reserved.
Author : Paul Hamaker. Part of JavaLessons.com
This code is for educational purposes only. Use at own risk.*/

1. import java.awt.event.* ; 

2. import java.awt.* ; 

3. import java.applet.*; 

4.  

5. public class StrMeth 

6.   extends Applet 

7.   implements ActionListener 

8.

9.   String stremail = "fred@rockbed.org"

10.  

11.   public void actionPerformed( ActionEvent ev ) 

12.   { 

13.     if ( stremail.equals ( "fred@rockbed.org" )  )   

14.       ta.append ( "Duhbaduhbayou !!!\n" ) ; 

15.  

16.     int  len, pos ; 

17.  

18.     len = stremail.length ();  

19.  

20.     ta.append ( len  + "\n" ); 

21.  

22.  

23.     pos = stremail.indexOf ( '@' ) ;  

24.  

25.     if ( pos == -1

26.     { 

27.       ta.append ( "Not a valid email address\n"); 

28.       return

29.     } 

30.  

31.     String  strleft, strright ; 

32.  

33.     strleft = stremail.substring ( 0, pos ) ;  

34.     ta.append ( strleft + "\n" ) ; 

35.  

36.     strright = stremail.substring ( pos + 1 ) ; 

37.     ta.append ( strright + "\n" ) ; 

38.  

39.  

40.   } 

41.   public StrMeth () 

42.   { 

43.     bt = new Button ( "Split" ) ; 

44.     ta = new TextArea (  12, 50 ) ; 

45.   } 

46.  

47.   public void init() 

48.   { 

49.     bt.addActionListener ( this ) ; 

50.     setBackground ( Color.lightGray ) ; 

51.  

52.     add ( ta ) ; 

53.     add ( bt ) ; 

54.     validate () ; 

55.   } 

56.  

57.   TextArea ta ; 

58.   Button bt ; 

59.

60. /*========================== 

61. - equalsIgnoreCase ( String

62. - indexOf ( String

63.     lookup a string. 

64. - indexOf ( String, int startpos ) 

65.     lookup string from startpos. 

66. - lastIndexOf ( String

67.     start at the righthand side. 

68. - startsWith ( String

69. - endsWith ( String

70. - toLowerCase( ) 

71.     makes a new lower case string copy. 

72. - charAt ( int pos ) 

73.     character at pos. 

74. - trim( ) 

75.     makes copy, white space removed from both ends. 

76. */