22 11 11910 java strings a string is a blend of

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: hat accesses a static field public staLc void setString(String aString) { theString = aString; } public staLc void main(String args) { setString(“bonjour monde !”); System.out.println(getString()); } } static method that accesses a local var static method that accesses a static method CPSC 324 ‐‐ Spring 2010 21 Static Methods •  What about this version? public class HelloAgainWorld { a non-static field public String theString = “Hello World!”; public String getString() { return theString; } public void setString(String aString) { theString = aString; } public staLc void main(String args) { setString(“bonjour monde !”); System.out.println(getString()); } } CPSC 324 ‐‐ Spring 2010 non-static method that accesses a static field (this is ok) non-static method that accesses a local var (this is ok) static method that accesses a non-static method (NOT OK!) 22 11 1/19/10 Java Strings • ...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online