SCJA String study preperation

Here is a short class I wrote to help with studying for the SCJA (section 4)... if anyone can add any other examples to it, please do.

publicclass strings{

publicstatic String scjaString ="This is the SCJA String Test! ";

publicstaticvoid main (String args[])

{

System.out.println (scjaString);

//startsWith

System.out.println (scjaString.startsWith("is",10));//ture

System.out.println (scjaString.startsWith("This"));//true

System.out.println (scjaString.startsWith("That"));//false

//endsWith

System.out.println (scjaString.endsWith("Test! "));//true

System.out.println (scjaString.endsWith("Test "));//false

//length

System.out.println (scjaString.length());//36

//substring

System.out.println (scjaString.substring(17,21));//SCJA

System.out.println (scjaString.substring(17));//SCJA String Test!

//trim

System.out.print (scjaString.trim());

System.out.println (scjaString.trim());

//This is the SCJA String Test!This is the SCJA String Test!

//indexOf

System.out.println(scjaString.indexOf('i'));//7

System.out.println(scjaString.indexOf("is"));//7

System.out.println(scjaString.indexOf("ing",10));//25

//charAt

System.out.println(scjaString.charAt(13));//t

//replace

System.out.println(scjaString.replace('A','P'));//This is the SCJP String Test!

System.out.println(scjaString.replace("This","That"));//That is the SCJA String Test!

}

}

Message was edited by:

javarob

[2987 byte] By [javaroba] at [2008-1-25]
# 1

Looks good. That's the core of what you need to know for the String section of the SCJA Exam

http://studyguides.scja.com/ExamScam/sunjavacertifiedtutorialsandmockexams.jsp?link=mockexams

As far as SCJA study guides and study notes for the Sun Certified Java Associates exam, you can find them here:

http://www.mcnz.com/ExamScam/get.jsp?link=books

Enjoy!

-Cameron McKenzie

http://www.scja.com

http://ww.portorials.com

http://www.scwcd.com

PulpJavaa at 2007-7-8 > top of java,Java Essentials,Training...