English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Hello-
I am in a Java begginers college course,and I am totally confused.How do you open the program to review it??I thought somehow you could open it with IE like html??I need a detail answer please..The instructor keeps telling me the assignments are wrong...We are using Eclipse if that helps to answer my question...Here is an example.He said this is not a runable program.
public class kab04_01 {


public static char upperCaseToLowerCase(char ch)
{
return (ch >= 'A' && ch <='Z') ? (char)(Math.random() * 26 + 'a') : ch;
}

How an suppose to declare if it is or not???

2007-12-05 03:35:20 · 2 answers · asked by Anonymous in Education & Reference Homework Help

2 answers

What you have here is an 'object' that is intended to be incorproated into a runnable program - that is, a program with a main function. And this isn't even an object; it has behaviour, but no state; all it can do is run a method. And I see little point in converting an upper-case letter into a random lower-case letter. Anyway, here's a runnable program that uses your class...

public class MyJavaProgram{
  public static void main ( string [] args ){
    char c = 'A';
    char d = kab04_01.upperCaseToLowerCase(ch);
    System.out.println("The value returned was " + c);
  }
}

Comments as a long-time Java professor: making new students use Eclipse is cruel and unusual punishment, as is using a text with class names like kab04_01.

2007-12-05 03:49:46 · answer #1 · answered by jgoulden 7 · 0 0

//add this method:
public static void main(String[] args)
{//write the declearation code here, and run it;
}

2007-12-05 11:48:23 · answer #2 · answered by hong_wei886 3 · 0 0

fedest.com, questions and answers