Wibble_
asked on
EASY - silly question from a beginner...
////////////////////////// ////////// ////////// //////
public class welcome {
/**
* @param args
*/
public static void main(String[] args) {
String strOne = "this is a string";
int intOne = NumberOfBytes(strOne);
System.out.println(strOne) ;
System.out.println(intOne) ;
}
}
class NumberOfBytes{
int storage (String s){
return s.length() * 2;
}
}
////////////////////////// ////////// ////////// //////////
says:
the method NumberOfBytes(String) is undefined for the method welcome
why?
public class welcome {
/**
* @param args
*/
public static void main(String[] args) {
String strOne = "this is a string";
int intOne = NumberOfBytes(strOne);
System.out.println(strOne)
System.out.println(intOne)
}
}
class NumberOfBytes{
int storage (String s){
return s.length() * 2;
}
}
//////////////////////////
says:
the method NumberOfBytes(String) is undefined for the method welcome
why?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
////////////////////////// ////////// ////////// //////
public class welcome {
/**
* @param args
*/
public static void main(String[] args) {
String strOne = "this is a string";
int intOne = NumberOfBytes.storage(strO ne);
System.out.println(strOne) ;
System.out.println(intOne) ;
}
static class NumberOfBytes{
static int storage (String s){
return s.length() * 2;
}
}
}
////////////////////////// ////////// /////////
Hurrah! Thank you CEHJ. It needs to be static, because otherwise it doesn't exist...
yay.
public class welcome {
/**
* @param args
*/
public static void main(String[] args) {
String strOne = "this is a string";
int intOne = NumberOfBytes.storage(strO
System.out.println(strOne)
System.out.println(intOne)
}
static class NumberOfBytes{
static int storage (String s){
return s.length() * 2;
}
}
}
//////////////////////////
Hurrah! Thank you CEHJ. It needs to be static, because otherwise it doesn't exist...
yay.
:-)
>>class NumberOfBytes{
to
static class NumberOfBytes{
and
>>int intOne = NumberOfBytes(strOne);
to
int intOne = NumberOfBytes.storage(strO