Results 1 to 3 of 3
  1. #1
    danielki is offline Member
    Join Date
    Feb 2014
    Posts
    16
    Rep Power
    0

    Default Java Introducing an object

    Hello, I am new to java oop. The following is my first program and can any one help me what
    I am missing that I couldn't get the task right? Thank you in advance!
    Task:The main method of the class Things below creates an object called printer deriving from the class PrintingClass and uses that object to print text. Your task is to write the PrintingClass class.

    Program to complete:
    Java Code:
    mport java.util.Scanner;
    
    
    public class Things {
    
        public static void main(String args[]) {
    
            String characterString;
    
            Scanner reader =  new Scanner(System.in);        
    
            PrintingClass printer = new PrintingClass();
    
           
    
            System.out.print("Type in the character string for printing: ");
    
            characterString = reader.nextLine();
    
            printer.Print(characterString);
    
        }
    
    }
    
    
    //  Write the missing class here
    
    //  Class is written in the text box below.
    Note: In this exercise the solution is part of a conversion unit where many classes have been declared. Because of this the classes are not declared as public using the public attribute.
    Example output


    Type in the character string for printing: John Doe
    John Doe
    My Class:

    Java Code:
    class PrintingClass {
      public void print(){
      System.out.println(characterString);
      
      
      
      }
    }

  2. #2
    kneitzel is offline Senior Member
    Join Date
    Feb 2014
    Posts
    447
    Rep Power
    1

    Default Re: Java Introducing an object

    Your print method does not have parameters. But you want to pass an Argument to it....

    Konrad

  3. #3
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,365
    Rep Power
    6

    Default Re: Java Introducing an object

    On top of that the method is called print(), yet the Things class is calling a method name Print(). Java is case sensitive.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. Introducing myself
    By unideal in forum Introductions
    Replies: 6
    Last Post: 01-04-2010, 03:43 AM
  2. Introducing myself
    By einsteinwallah in forum Introductions
    Replies: 0
    Last Post: 01-05-2009, 07:40 PM
  3. Introducing, Tim.
    By tim in forum Introductions
    Replies: 2
    Last Post: 12-25-2007, 06:14 PM
  4. Introducing Myself
    By gulapala in forum Introductions
    Replies: 1
    Last Post: 12-25-2007, 09:59 AM
  5. Introducing Cocoon And Orbeon
    By peiceonly in forum Web Frameworks
    Replies: 1
    Last Post: 04-19-2007, 06:47 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •