1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

I need help with JAVA homework.?

Discussion in 'Java' started by pakman, May 3, 2010.

  1. pakman

    pakman New Member

    Joined:
    May 3, 2010
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    "i have java homework that i am not sure how to do, i mean i have most of it done but need a little help completing it. below is the directions my professor gave us that we have to follow."

    "Please refer to JAVA API Specification(API WEBSITE) and find the "String" Class. Write an application and try to use eight different methods of the String class as was demonstrated in class. (examples: selecting portions of a string, manipulating strings such as changing all characters to uppercase or lowercase, counting the length of a string, etc)"


    "This is what i have done below"

    import java.util.Scanner;
    public class String
    {
    public static void main(String args[ ] )
    {
    Scanner input = new Scanner(System.in );
    System.out.print( " Please enetr some text: ");
    String txt = input.nextLine();
    System.out.println( " you entered: " + txt);
    System.out.println("the length of the text is: " + txt.length() ) ;
    System.out.println( "After change: " );
    System.out.println( txt.replace("God", "Allah") );
    System.out.println( "After lower case change: " );
    System.out.println( txt.toLowerCase() );
    System.out.println( "After Upper case change: " );
    System.out.println( txt.toUpperCase() );
    }
    }

    "every time i compile i am getting an error message and also can someone help me complete the rest of this. I have to turn this in within 10 hours. THANK YOU"
     
  2. Noam

    Noam New Member

    Joined:
    Jun 4, 2010
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    i'm not 100 sure, but i think the problem is you calling the class "String"
    change it to something different than java's reserved words, like "StringWork" or something
     

Share This Page