Implement method inside abstract class?

hello everyone:
I have a question regarding implementation of method inside a abstract class. The abstract class has a static method to swamp two numbers.
The problem ask if there is any output from the program; if no output explain why?
This is a quiz question I took from a java class. I tried the best to recollect the code sample from my memory.
if the code segment doesn't make sense, could you list several cases that meet the purpose of the question. I appreciate your help!
code sample
public abstract class SwampNumber
   int a = 4;
   int b = 2;
   System.out.println(a);
   System.out.println(b);
   swamp(a, b);
   public static void swamp(int a, int b)
     int temp = a;
         a = b;
         b = a;
     System.out.println(a);
     System.out.println(b);

It won't compile.
You can't instantiate an abstract class before you know anything.
//somewhere in main
SwampNumber myNum = new SwampNumber();
//Syntax ErrorQuote DrClap
This error commonly occurs when you have code that >>is not inside a method.
The only statements that can appear outside methods >>in a Java class are >>declarations.Message was edited by:
lethalwire

Similar Messages

  • Native methods inside C++ class

    Hey all,
    Tried posting this already but it didn't appear in the forums. So apologies if this appears twice on same forum :o)
    Want to wrap my native methods inside a C++ class but get UnsatisfiedLinkerError when I do. Is it possible to do this? Do I have to change some method signatures or what?
    I want something like :
    public class A
    native void doSomething();
    class B
    public:
    JNIEXPORT void JNI Java_A_doSomething() { ... } /* or whatever */
    It works ok outside of a C++ class but I'd prefer to contain my methods inside a class. Any help?
    Cheers,
    Conor

    Java needs to find your functions in the DLL or SO. But the names are "mangled" if you declare the function inside a class - even declaring the function "static" does not help. For instance, using the Microsoft C++ compiler:
    class B
    public:
    static JNIEXPORT void JNI Java_A_doSomething() { ... }
    };the name is mangled to ?Java_A_doSomething@B@@SAXXZ
    But Java tries to locate the entry _Java_A_doSomething@0 in the DLL.
    You can write the global functions as:
    JNIEXPORT void JNI Java_A_doSomething() {
        B::doSomething();
    }and implement your functions in the class B. The advantage of this approach is that you can write all bookkeeping work of converting Java data to C++ data in the global function, and leave the real work to the function declared in the C++ class.

  • What is the purpose of Static methods inside a class?

    Hi,
    What is the purpose of Static methods inside a class?
    I want the answers apart from "A static method does not require instance of class(to access) and it can directly be accessed by the class name itself"
    My question is what is the exact purpose of a static method ?
    Unlike attributes, a separate copy of instance attributes will be created for each instance of a class where as only one copy of static attributes will be created for all instances.
    Will a separate copy of instance method be created for each instance of a class and only one copy of static methods be create?
    Points will be rewarded for all helpful answers.

    Hi Sharma,
    Static methods is used to access statics attributes of a class. We use static attributes when we want to share the same attribute with all instances of a class, in this case if you chage this attribute through the instance A this change will change will be reflected in instance B, C........etc.
    I think that your question is correct -> a separate copy of instance method will be created for each instance of a class and only one copy of static methods be create ?
    "A static method does not require instance of class(to access) and it can directly be accessed by the class name itself"
    Static Method: call method class=>method.
    Instance Method: call method instance->method.
    Take a look at this wiki pages.
    [https://wiki.sdn.sap.com/wiki/x/o5k]
    [https://wiki.sdn.sap.com/wiki/x/ZtM]
    Best regards.
    Marcelo Ramos

  • Final methods in abstract classes?

    Hi, why is it possible to define a final method in an abstract class? The theory behind a final method doesn't say that a final method couldn't be overridden?
    Marco

    So it's formally correct but it doesn't have any
    sense, does it?You sound very confused. A final method in an
    abstract class has just the same semantics and
    makes just as much sense as in a non-abstract
    class.
    The semantics of a final method is simply that
    it cannot be overridden in subclassed. Both
    abstract and non-abstract classes can be
    subclasses. So why do you think there should be any
    difference?Actually i was confused now it's clear. I was too binded to the concept that the extending class SHOULD(not for a formal reason, but for a 'design' one) write the implementation of the methods defined in the abstract class. Now i see that, actually, by defining a final method in an abstract class we are defining our design as implemented and clients(i.e. subclasses) can only use it.
    Thank you,
    Marco

  • I really need abstract static methods in abstract class

    Hello all.. I have a problem,
    I seem to really need abstract static methods.. but they are not supported.. but I think the JVM should implement them.. i just need them!
    Or can someone else explain me how to do this without abstract static methods:
    abstract class A {
    abstract static Y getY();
    static X getX() {
        // this methods uses getY, for example:
        y=getY();
       return new X(y); // or whatever
    class B extends A {
    static Y getY() { return YofB; }
    class C extends A {
    static Y getY() { return YofC; }
    // code that actually uses the classes above:
    // these are static calls
    B.getX();
    A.getX();I know this wont compile. How should i do it to implement the same?

    Damn i posted this in the wrong thread.. anyways.
    Yes offcourse i understand abstract and static
    But i have a problem where the only solution is to use them both.
    I think it is theoretically possible ot implement a JVM with support for abstract static methods.
    In fact it is a design decision to not support abstract static methods.. thats why i am asking this question.. how could you implemented this otherwise?
    There is an ugly soluition i think: using Aspect Oriented Programming with for example AspectJ.. but that solution is really ugly. So anyone has an OO solution?

  • Dynamically invoke methods of abstract class?

    Hi,
    I am using reflection to write a class (ClassA) to dynamically invoke methods of classes. I have an abstract class (ClassB) that has some of the methods already implemented, and some of the methods that are declared abstract. Is there any way that I can:
    (a) invoke the methods that are already implemented in ClassB;
    (b) I have another class (ClassC) that extends ClassB, some of the methods are declared in both classes. Can I dynamically invoke these methods from ClassB?
    Thanks in advance,
    Matt.

    Ok, the program is quite long, as it does other things as well, so I'll just put in the relevant bits.
    What I have is a JTree that displays classes selected by the user from a JFileChooser, and their methods.
    // I declare a variable called executeMethod
    private static Method executeMethod;
    // objectClass is a class that has been chosen by the user.  I create a new instance of this class to execute the methods.
    Object createdObject = objectClass.newInstance();
    // methodName is the method selected by the user.  objectClassMethods is an array containing all the methods in the chosen class.
    executeMethod = objectClassMethods[j].getDeclaringClass().getMethod(methodName, null);
    Object executeObject = executeMethod.invoke(createdObject, new Object[]{});Ok, here are the test classes:
    public abstract class ClassB{
         private int age;
         private String name;
         public ClassB(){ age = 1; name="Me";}
         public int getAge(){ return age; }
         public String getName(){ return name; }
         public void PrintAge(){System.out.println(age);}
         public void PrintName(){System.out.println(name);}
         public abstract void PrintGreeting();
    public class ClassC extends ClassB{
         public ClassC(){super();}
         public void PrintAge(){
              System.out.println("I am " + getAge() + " years old.");
         public void PrintGreeting(){
           System.out.println("Hello");
    }Now, I can print out the PrintAge method from ClassC (i.e. have it output "Hello" to the command line, how can I, say, get it to output the result of PrintName from ClassB, this method does not appear in ClassC. As you can see at the top, I can create a new instance of a normal method (in this case, ClassC), and have it output to the command line, but I know that I can't create a new instance of an abstract class. And since PrintName is implemented in abstract class ClassB, how do I get it to output to the command line?
    Thanks,
    Matt.

  • Protected methods in abstract classes

    Hello All
    I have some problem which I cannot find a workaround for.
    I have three classes:
    package my.one;
    public abstract class First {
      protected void do();
      protected void now();
    package my.one;
    public class NotWantToHave extends First {
      protected First obj;
      public NotWantToHave(First O) { obj = O; }
      public void do() { obj.do(); }
      public void now() { obj.now(); }
    package my.two;
    public class Second extends my.one.First {
      protected void do() { System.out.println("Second does"); }
      protected void now() { System.out.println("Second does now"); }
    package my.three;
    public class Three extends my.one.First {
      protected my.one.First obj;
      public Three(my.one.First O) { obj = O; }
      protected void do() { System.out.println("Doing"); }
      protected void now() { obj.now(); } // Not possible, see later text
    Problem is, as one can read in http://java.sun.com/docs/books/tutorial/java/javaOO/accesscontrol.html , it says that you cannot access protected members and methods from classes if they are in a different package. However, since my class Three should not concern about the method now() but should use from some other class that implements (i.e. class Second), the question I have is how to do?
    One way would be to implement a class that simply make a forward call to any protected method in the same package the abstract class is in like in class NotWantToHave and pass it to the constructor of class Third while this class was created with an instance of class Second. However, such a call would look very clumsy (new my.three.Third(new my.one.NotWantToHave(new my.two.Second()));). Furthermore, everyone could create an instance of class NotWantToHave and can invoke the methods defined as protected in class First, so the access restriction would be quite useless.
    Does anyone has a good idea how to do?

    Hi
    One way I found is to have a nested, protected static final class in my super-class First and provide a protected static final method that returns a class where all methods of the super-class are made public and thus accessible from sub-classes at will. The only requirement is that a sub-class must invoke this method to encapsulate other implementations of the super-class and never publish the wrapper class instance. This will look as follows:
    package my.one;
    public abstract class First {
      protected final static class Wrap extends First { // extend First to make sure not to forget any abstract method
        protected First F;
        public void do() { F.do(); }
        public void now() { F.now(); }
        protected Wrap(First Obj) { F = Obj; }
      } // end Wrap
      protected final static First.Wrap wrap(First Obj) { return new First.Wrap(Obj); }
      protected abstract void do();
      protected abstract void now();
    } // end First*******
    package my.two;
    public class Second extends my.one.First {
      protected void do() { System.out.println("Second does"); }
      protected void now() { System.out.println("Second does now"); }
    } // end Second*******
    package my.three;
    public class Three extends my.one.First {
      protected my.one.First.Wrap obj;
      public Three(my.one.First O) { obj = my.one.First.wrap(O); }
      protected void do() { System.out.println("Doing"); }
      protected void now() { obj.now(); } // Not possible, see later text
    } // end Third*******
    In this way, I can access all methods in the abstract super class since the Wrap class makes them public while the methods are not accessible from outside the package to i.e. a GUI that uses the protocol.
    However, it still looks clumsy and I would appreciate very much if someone knows a more clear solution.
    And, please, do not tell me that I stand on my rope and wonder why I fall down. I hope I know what I am doing and of course, I know the specification (why else I should mention about the link to the specification and refer to it?). But I am quite sure that I am not the first person facing this problem and I hope someone out there could tell me about their solution.
    My requirements are to access protected methods on sub-classes of a super-class that are not known yet (because they are developed in the far, far future ...) in other sub-classes of the same super-class without make those methods public to not inveigle their usage where they should not be used.
    Thanks

  • Can i call non -abstract method in abstract class into a derived class?

    Hi all,
    Is it possible in java to call a non-abstract method in a abstact class from a class derived from it or this is not possible in java.
    The following example will explain this Ques. in detail.
    abstract class A
    void amethod()
    System.out.println(" I am in Base Class");
    public class B extends A
    void amethod()
    System.out.println(" I am in Derived Class");
    public static void main (String args[])
    // How i code this part to call a method amathod() which will print "I am in Base Class
    }

    Ok, if you want to call a non-static method from a
    static method, then you have to provide an object. In
    this case it does not matter whether the method is in
    an abstract base class or whatever. You simply cannot
    (in any object oriented language, including C++ and
    JAVA) call a nonstatic method without providing an
    object, on which you will call the method.
    To my solution with reflection: It also only works,
    if you have an object. And: if you use
    getDeclaredMethod, then invoke should not call B's
    method, but A's. if you would use getMethod, then the
    Method object returned would reflect to B's method.
    The process of resolving overloaded methods is
    performed during the getMethod call, not during the
    invoke (at least AFAIK, please tell me, if I'm wrong).You are wrong....
    class A {
        public void dummy() {
             System.out.println("Dymmy in A");
    class B extends A {
         public void dummy() {
              System.out.println("Dymmy in B");
         public static void main(String[] args) throws Exception {
              A tmp = new B();
              Class clazz = A.class;
              Method method = clazz.getDeclaredMethod("dummy", null);
              method.invoke(tmp, null);
    }Prints:
    Dymmy in B
    /Kaj

  • CRM 7.0 implement method from MVC class

    Hello, folks.  I will prefix my question with the fact that I am a relative dinosaur in the development arena, still focused primarily procedural coding practices.  Although this still serves me well, it also means that I know little about OO development.  I have had some training and can make use of such common tools as OO ALV.  However, I know next to nothing about MVC (model view controller) programming, WEB Dynpro for ABAP, etc.  I am currently assigned to a CRM project (I am also new to CRM) and have a particular requirement that I cannot seem to address with any sort of procedural-based solution (i.e. function module).
    My requirement is to create a "URL Attachment" to a service request in CRM.  To elaborate, I have created an inbound point-to-point interface (i.e. not PI/XI) from an external system using Web Services.  The Web Service I have created ultimately invokes a call to function CRMXIF_ORDER_SAVE via a wrapper function I developed with the same interface.  This function, however, does not support the creation of "URL Attachments", only "Attachment Links".  So, my approach then is to implement additional functionality in my wrapper function to create this URL Attachment via some other means.  If you have any questions regarding URL Attachments vs. Attachment Links, please let me know.
    I have scoured the function modules to no avail.  What I have found is that via MVC, the functionality on the CRM Web UI is associated with the following class: CL_GS_CM_ADDURL_IMPL.  A search in SE24 reveals that there are actually several related? classes:
    CL_GS_CM_ADDURL
    CL_GS_CM_ADDURL_CN02
    CL_GS_CM_ADDURL_CN03
    CL_GS_CM_ADDURL_CTXT
    CL_GS_CM_ADDURL_IMPL
    My question is whether I can somehow implement one of these classes to address my requirement.  Looking at the logic within the IP_TO_ADDURL method, I cannot figure out whether I can somehow leverage this and, if so, exactly what coding would be required in my wrapper function.  I should also point that, at least from a Web UI point of view, this is a two step process whereby you must first create the attachment and the actually save it. 
    Any and all insights are much appreciated.
    Thanks.

    Hi there,
    I am not familiar with the CRM classes you mention - but what you describe is pretty much standard functionality included in Generic Object Services. May that path will lead you home.
    Cheers
    Graham Robbo

  • Using common methods with abstract classes

    hello everyone, i wanted to know if it is bad practice (i imagine it is) to place methods which will be used by multiple classes (computational methods) in an abstract class and mark them as static. When i do this they are always project wide utility classes which dont need an instantiation. When using any of these methods which are common to a project i can then just use..
    Type result = ClassName.DoStaticMethod(...);Thanks for any input,
    Dori
    Edited by: Sir_Dori on Dec 8, 2008 2:01 AM

    Depends on what the methods are meant to do, but I wouldn't make the class abstract. I would instead declare it to be final and have a private constructor.
    Kaj
    Ps. Take a look at the java.lang.Match class.

  • Implementing methods in a class

    I have a class called Employee that uses getters and seters and methods from another project. I brought the code from the methods into the Employee class to run them in my class. It is supose to calculate an employee's monthly income plus commission and a seniority bonus based on years. When I compile the class I get errors. I was wondering if you java experts can look and see what my problem is. Here is the code and errors, thanks...
    public class Employee
         private String firstName, lastName,
              address, city, state,zipCode;
         private short seniority = 0;
         private double baseSalary = 500;
         private Company company;
         //constructor
         public Employee(String fn, String ln, String a, String c, String s,
              String zc, short newSeniority, double newBs, Company newCompany){
              firstName = fn;
              lastName = ln;
              address = a;
              city = c;
              state = s;
              zipCode = zc;
              seniority = newSeniority;
              baseSalary = newBs;
              company = newCompany;
         public Employee(){
              firstName = "";
              lastName = "";
              address = "";
              city = "";
              state = "";
              zipCode = "";
         public double computeCommision(double weeklyPay) {
              double thisCommission;   
           if(weeklyPay < baseSalary)
                  thisCommission = 0.00;   
           else if(weeklyPay < 1000.00)
              thisCommission = weeklyPay * .05;   
           else if(weeklyPay < 5000.00)
              thisCommission = weeklyPay * .08;   
           else if(weeklyPay >= 5000.00)
              thisCommission = weeklyPay * .10 + 400;   
           else thisCommission = 0.00;  
           return thisCommission;
         public double bonus(double weeklyPay, int yearsWorked) {
              short seniority;
            double thisCommission = computeCommission(weeklyPay);
            if (yearsWorked >= 2) // No bonus for less than two years
                 seniority = (weeklyPay * yearsWorked)/100;
            return seniority;
         public double payroll() {
              double payroll = 0.0, pay, commission, bonus, years;
            System.out.println("\nPlease enter the years you have worked for this company:");
            int response = MyInput.readInt();
            for (int i = 0; i < 4; i++)
            System.out.println("\nPlease enter you salary for week "  + (i+1) + ": ");
            pay = MyInput.readDouble();
            commission =  computeCommission(pay);
            bonus = bonus((commission + pay), response);
            payroll = payroll + pay + commission + bonus;     
            return payroll;
         public String getFirstName() { return firstName; }
         public void setFirstName(String fn) { firstName = fn; }
         public String getLastName() { return lastName; }
         public void setLastName(String ln) { lastName = ln; }
         public String getAddress() { return address; }
         public void setAddress(String a) { address = a; }
         public String getCity() { return city; }
         public void setCity(String c) { city = c; }
         public String getState() { return state; }
         public void setState(String s)     { state = s; }
         public String getZipCode()     { return zipCode; }
         public void setZipCode(String zc) { zipCode = zc; }
         public short getSeniority() { return seniority; }
         public void setSeniority(short newSeniority) { seniority = newSeniority; }
         public double getBaseSalary() { return baseSalary; }
         public void setBaseSalary(double newBs) { baseSalary = newBs; }
         public Company getCompany() { return company; } //getter method for company in company class
         public void setBank(Company newCompany) { company = newCompany; }
    }   and the errors are :
    C:\cis163\Project5_1\src\Employee.java:59: cannot resolve symbol
    symbol : method computeCommission (double)
    location: class Employee
    double thisCommission = computeCommission(weeklyPay);
    ^
    C:\cis163\Project5_1\src\Employee.java:62: possible loss of precision
    found : double
    required: short
    seniority = (weeklyPay * yearsWorked)/100;
    ^
    C:\cis163\Project5_1\src\Employee.java:70: cannot resolve symbol
    symbol : variable MyInput
    location: class Employee
    int response = MyInput.readInt();
    ^
    C:\cis163\Project5_1\src\Employee.java:75: cannot resolve symbol
    symbol : variable MyInput
    location: class Employee
    pay = MyInput.readDouble();
    ^
    C:\cis163\Project5_1\src\Employee.java:76: cannot resolve symbol
    symbol : method computeCommission (double)
    location: class Employee
    commission = computeCommission(pay);
    ^
    5 errors

    ok, sorry. I wasnt clear on what you were saying. MyInput.java is in the same folder when I compiled it. I changed my code around a little, changed some variables so it was easier for me to understand. I am still getting several errors after I wrote code for the Project which I called project5. Not sure where I am going wrong but I will post my classes and main to see if anyone can help me out.
    //Company class
    public class Company
        private String companyName;
         private String companyAddress;
         private String companyCity;
         private String companyState;
         private String companyZip ;
         //Constructor method
         public Company(String cn, String ca, String cc, String cs, String cz) {
              companyName = cn;         
              companyAddress = ca;         
              companyCity = cc;         
              companyState = cs;         
              companyZip = cz;
        public Company(){
             companyName = "";
             companyAddress = "";
             companyCity = "";
             companyState = "";
             companyZip = "";
         public String getName() { return companyName; }
        public void setName(String cn) { companyName = cn; }
         public String getAddress() { return companyAddress; }
        public void setAddress(String ca){ companyAddress = ca; }
        public String getCity() { return companyCity; }
        public void setCity(String cc) { companyCity = cc; }     
        public String getState() { return companyState; }     
        public void setState(String cs) { companyState = cs; }
        public String getZip()     { return companyZip; }     
        public void setZip(String cz) { companyZip = cz; }
    //Employee class
    public class Employee
         private String employeeFName, employeeLName,employeeAddress,
              employeeCity, employeeState, employeeZip;
         private short seniority = 0;
         private double baseSalary = 500;
         private Company company;
         //constructor
         public Employee(String efn, String eln, String ea, String ec, String es,
              String ez, short newSeniority, double newBs, Company newCompany){
              employeeFName = efn;
              employeeLName = eln;
              employeeAddress = ea;
              employeeCity = ec;
              employeeState = es;
              employeeZip = ez;
              seniority = newSeniority;
              baseSalary = newBs;
              company = newCompany;
         public Employee(){
              employeeFName = "";
              employeeLName = "";
              employeeAddress = "";
              employeeCity = "";
              employeeState = "";
              employeeZip = "";
         public double computeCommission(double weeklyPay) {
              double thisCommission;   
           if(weeklyPay < baseSalary)
                  thisCommission = 0.00;   
           else if(weeklyPay < 1000.00)
              thisCommission = weeklyPay * .05;   
           else if(weeklyPay < 5000.00)
              thisCommission = weeklyPay * .08;   
           else if(weeklyPay >= 5000.00)
              thisCommission = weeklyPay * .10 + 400;   
           else thisCommission = 0.00;  
           return thisCommission;
         public double bonus(double weeklyPay, int yearsWorked) {
              short seniority;
            double thisCommission = computeCommission(weeklyPay);
            if (yearsWorked >= 2) // No bonus for less than two years
                 seniority = (short) ((weeklyPay * yearsWorked)/100);
            return seniority;
         public double payroll() {
              double payroll = 0.0, pay, commission, bonus, years;
            System.out.println("\nPlease enter the years you have worked for this company:");
            int response = MyInput.readInt();
            for (int i = 0; i < 4; i++)
            System.out.println("\nPlease enter you salary for week "  + (i+1) + ": ");
            pay = MyInput.readDouble();
            commission =  computeCommission(pay);
            bonus = bonus((commission + pay), response);
            payroll = payroll + pay + commission + bonus;     
            return payroll;
         public String getFirstName() { return employeeFName; }
         public void setFirstName(String efn) { employeeFName = efn; }
         public String getLastName() { return employeeLName; }
         public void setLastName(String eln) { employeeLName = eln; }
         public String getAddress() { return employeeAddress; }
         public void setAddress(String ea) { employeeAddress = ea; }
         public String getCity() { return employeeCity; }
         public void setCity(String ec) { employeeCity = ec; }
         public String getState() { return employeeState; }
         public void setState(String es)     { employeeState = es; }
         public String getZipCode()     { return employeeZip; }
         public void setZipCode(String ez) { employeeZip = ez; }
         public short getSeniority() { return seniority; }
         public void setSeniority(short newSeniority) { seniority = newSeniority; }
         public double getBaseSalary() { return baseSalary; }
         public void setBaseSalary(double newBs) { baseSalary = newBs; }
         public Company getCompany() { return company; } //getter method for company in company class
         public void setBank(Company newCompany) { company = newCompany; }
    public class Project5 { //Beginning of class Project5
    public static void main (String args[]) { //Beginning of main
            //Company
            String companyName = "";
            String companyAddress = "";
            String companyCity = "";
            String companyState = "";
            String companyZip = "";
            // Creates a new Company object called aCompany
            Company aCompany = new Company( companyName, companyAddress,
                 companyCity, companyState, companyZip );
            // Prompts user about information about company
            // and sets fields for the Company object.
            System.out.println( "***Company Information***" );
            System.out.println( "Please enter information about company:");
            System.out.println();
            System.out.print( "Company name: " );
            companyName = MyInput.readString();
            aCompany.setName( companyName );
            System.out.print( "Company address: " );
            companyAddress = MyInput.readString();
            aCompany.setAddress( companyAddress );
            System.out.print( "Company city: " );
            companyCity = MyInput.readString();
            aCompany.setCity( companyCity );
            System.out.print( "Company state: " );
            companyState = MyInput.readString();
            aCompany.setState( companyState );
            System.out.print( "Company zip: " );
            companyZip = MyInput.readString();
            aCompany.setZip( companyZip );
            System.out.println();
            // Employee
            String employeeFName = "";
            String employeeLName = "";
            short seniority = 0;
            String employeeAddress = "";
            String employeeCity = "";
            String employeeState = "";
            String employeeZip = "";
            // Creates a new Employee object called anEmployee who works for the above company.
            Employee anEmployee = new Employee( employeeFName,employeeLName, seniority,
                 employeeAddress, employeeCity, employeeState, employeeZip, aCompany );
            // Prompts user about information about employee
            // and sets fields for the Employee object.
            System.out.println( "***Employee Information***" );
            System.out.println( "Please enter information about an employee:");
            System.out.println();
            System.out.print( "Employee first name: " );
            employeeFName = MyInput.readString();
            anEmployee.setFirstName( employeeFName );
            System.out.print( "Employee last name: " );
            employeeLName = MyInput.readString();
            anEmployee.setLastName( employeeLName );
            System.out.print( "Employee address: " );
            employeeAddress = MyInput.readString();
            anEmployee.setAddress( employeeAddress );
            System.out.print( "Employee city: " );
            employeeCity = MyInput.readString();
            anEmployee.setCity( employeeCity );
            System.out.print( "Employee state: " );
            employeeState = MyInput.readString();
            anEmployee.setState( employeeState );
            System.out.print( "Employee zip: " );
            employeeZip = MyInput.readString();
            anEmployee.setZip( employeeZip );
            System.out.print( "How many years the employee has been with the company? : " );
            seniority = (short)MyInput.readInt();
            anEmployee.setSeniority( seniority );
            System.out.println();
            // Displays company information
            System.out.println( "*** Company Information Summary ***" );
            System.out.println( "Company name:    " + aCompany.getName());
            System.out.println( "Company address: " + aCompany.getAddress() );
            System.out.println( "Company city:    " + aCompany.getCity() );
            System.out.println( "Company state:   " + aCompany.getState() );
            System.out.println( "Company zip:     " + aCompany.getZip() );
            System.out.println();
            // Displays employee information
            System.out.println( "*** Employee Information Summary ***");
            System.out.println( "Employee firstName:  " + anEmployee.getFirstName() );
            System.out.println( "Employee lastName:   " + anEmployee.getLastName() );
            System.out.println( "Employee seniority:  " + anEmployee.getSeniority() );
            System.out.println( "Employee baseSalary: $" + anEmployee.getBaseSalary() );
            System.out.println( "Employee address:    " + anEmployee.getAddress() );
            System.out.println( "Employee city:       " + anEmployee.getCity() );
            System.out.println( "Employee state:      " + anEmployee.getState() );
            System.out.println( "Employee zip:        " + anEmployee.getZip() );
            // We retrieve the company name from anEmployee object.
            System.out.println( "Company name the employee works for: "
                 + anEmployee.getCompany().getName() );
            // Calls payroll() to calculate one month salary
            System.out.println();
            System.out.println( "*** Calculate monthly pay *** " );
            double oneMonthSalary = anEmployee.payroll(); // Calls payroll()
            DecimalFormat myDecimalFormat = new DecimalFormat( "0.00" );
    // Instantiate DecimalFormat object
            // Format one month salary and display to console
            System.out.println();
            System.out.println( "One month salary is: $" + myDecimalFormat.format(oneMonthSalary) );
            System.out.println();
    }sorry, its alot. I'm getting 18 errors, which are:
    C:\cis163\Project5_1\src\Project5.java:24: cannot resolve symbol
    symbol : variable MyInput
    location: class Project5
    companyName = MyInput.readString();
    ^
    C:\cis163\Project5_1\src\Project5.java:28: cannot resolve symbol
    symbol : variable MyInput
    location: class Project5
    companyAddress = MyInput.readString();
    ^
    C:\cis163\Project5_1\src\Project5.java:32: cannot resolve symbol
    symbol : variable MyInput
    location: class Project5
    companyCity = MyInput.readString();
    ^
    C:\cis163\Project5_1\src\Project5.java:36: cannot resolve symbol
    symbol : variable MyInput
    location: class Project5
    companyState = MyInput.readString();
    ^
    C:\cis163\Project5_1\src\Project5.java:40: cannot resolve symbol
    symbol : variable MyInput
    location: class Project5
    companyZip = MyInput.readString();
    ^
    C:\cis163\Project5_1\src\Project5.java:56: cannot resolve symbol
    symbol : constructor Employee (java.lang.String,java.lang.String,short,java.lang.String,java.lang.String,java.lang.String,java.lang.String,Company)
    location: class Employee
    Employee anEmployee = new Employee( employeeFName,employeeLName, seniority,
    ^
    C:\cis163\Project5_1\src\Project5.java:66: cannot resolve symbol
    symbol : variable MyInput
    location: class Project5
    employeeFName = MyInput.readString();
    ^
    C:\cis163\Project5_1\src\Project5.java:70: cannot resolve symbol
    symbol : variable MyInput
    location: class Project5
    employeeLName = MyInput.readString();
    ^
    C:\cis163\Project5_1\src\Project5.java:74: cannot resolve symbol
    symbol : variable MyInput
    location: class Project5
    employeeAddress = MyInput.readString();
    ^
    C:\cis163\Project5_1\src\Project5.java:78: cannot resolve symbol
    symbol : variable MyInput
    location: class Project5
    employeeCity = MyInput.readString();
    ^
    C:\cis163\Project5_1\src\Project5.java:82: cannot resolve symbol
    symbol : variable MyInput
    location: class Project5
    employeeState = MyInput.readString();
    ^
    C:\cis163\Project5_1\src\Project5.java:86: cannot resolve symbol
    symbol : variable MyInput
    location: class Project5
    employeeZip = MyInput.readString();
    ^
    C:\cis163\Project5_1\src\Project5.java:87: cannot resolve symbol
    symbol : method setZip (java.lang.String)
    location: class Employee
    anEmployee.setZip( employeeZip );
    ^
    C:\cis163\Project5_1\src\Project5.java:90: cannot resolve symbol
    symbol : variable MyInput
    location: class Project5
    seniority = (short)MyInput.readInt();
    ^
    C:\cis163\Project5_1\src\Project5.java:114: cannot resolve symbol
    symbol : method getZip ()
    location: class Employee
    System.out.println( "Employee zip: " + anEmployee.getZip() );
    ^
    C:\cis163\Project5_1\src\Project5.java:127: cannot resolve symbol
    symbol : method payroll ()
    location: class Employee
    double oneMonthSalary = anEmployee.payroll(); // Calls payroll()
    ^
    C:\cis163\Project5_1\src\Project5.java:129: cannot resolve symbol
    symbol : class DecimalFormat
    location: class Project5
    DecimalFormat myDecimalFormat = new DecimalFormat( "0.00" );
    ^
    C:\cis163\Project5_1\src\Project5.java:129: cannot resolve symbol
    symbol : class DecimalFormat
    location: class Project5
    DecimalFormat myDecimalFormat = new DecimalFormat( "0.00" );
    ^
    18 errors

  • Problem implementing Methods in a class

    Hi,
    I am trying to change this code :
    import java.util.Scanner;
    public class Test {
    public static void main(String[]args) {
    Scanner stdin = new Scanner(System.in);
    System.out.print("Number: ");
    double n = stdin.nextDouble();
    System.out.println(n + " * " + n + " = " + n*n);
    So that instead of everytime that I get in I have to create an a new state,
    I want to create it an object that could be access for every class
    and I did this but is not running:
    import java.util.Scanner;
    public class Miguel {
    public static void main(String[]args) {
    public double calc(double n)
    Scanner stdin = new Scanner(System.in);
    System.out.print("Number: ");
    double n = stdin.nextDouble();
    System.out.println(n + " * " + n + " = " + n*n);
    return n
    System.out.println(calc());
    }

    and I did this but is not running:Not only that, it's not compiling. You can't declare methods within methods, as you have done by attempting to declare calc() inside of main().
    When you post code, please post it between [code] and [/code] tags (you can just use the "code" button on the message posting screen). It makes your code much easier to read by preserving the original spacing, adding syntax highliting, and it prevents accidental markup from array indices like [i].

  • Error When Deleting a Method Inside a Class

    I developed a custom class that contained a private method. I removed this method because it was no longer needed. When moving the changes from the development to test client, it failed on import. For some reason, there was still some dependency on the method that was deleted.
    I went back to transaction SE24 and regenerated all the sections. When this was done, it regenerated the class definition and the various sections. I moved a transport that contained these changes and it still failed. The import log has a reference to an include that is failing, but I still see no mention of the method that was deleted.
    To continue going forward, I added the method back so that it resolved syntax error during import.
    I am suspecting that there is some issue with ABAP support pack being used on the development system. Have other people experienced the same issue. I don't have the habit of deleting that many methods once it is created, but would like to understand the above problem and see what should be the corrective action.
    Feedback/comments would be appreciated.
    Regards,
    Vince Castello

    As mentioned in my original post, I did re-generate all the sections using SE24, but the import still failed where the dependency to deleted method still remained.
    I am planning to create a customer message and will post results when they become available.
    Regards,
    Vince Castello

  • Implementation method SEARCH_FOR_NEXT_PROCESSOR of Class PT_GEN_REQ

    Hi All,
    we are trying to implement BADI u201CFind next processoru201D  of the implementation PT_GEN_REQ and we would like to filter the next processor according to the absence/attendance type which is not one of parameters of the method SEARCH_FOR_NEXT_PROCESSOR.
    Is there a way to do so?
    Thanks in advace for your help,
    Amedeo

    Hi Harald,
    to check the user defined entries, I suggest you implement it in the START_WF method. There's a method call:
        CALL METHOD lc_step->agent_append
          EXPORTING
            agent          = l_agent
          EXCEPTIONS
            already_exists = 1
            locked         = 2
            OTHERS         = 3.
    which adds the agents to the recipient list. The validation could be put before this I think.
    Hope this helps,
    Mikko

  • Non-abstract methods in a Abstract class

    Abstract Class can contain Non-abstract methods.
    and Abstract Classes are not instantiable as well
    So,
    What is the purpose of Non-abstract methods in a Abstract class.
    since we can't create objects and use it
    so these non-abstract methods are only available to subclasses.
    (if the subclass is not marked as abstract)
    is that the advantage that has.(availability in subclass)
    ??

    For example, the AbstractCollection class (in
    java.util) provides an implementation for many of the
    methods defined in the Collection interface.
    Subclasses only have to implement a few more methods
    to fulfill the Collection contract. Subclasses may
    also choose to override the AbstractCollection
    functionality if - for example - they know how to
    provide an optimized implementation based on
    characteristics of the actual subclass.Another example is the abstract class MouseAdapter that implements MouseListener, MouseWheelListener, MouseMotionListener, and that you can use instead of these interfaces when you want to react to one or two types of events only.
    Quoting the javadocs: "If you implement the MouseListener, MouseMotionListener interface, you have to define all of the methods in it. This abstract class defines null methods for them all, so you can only have to define methods for events you care about."

Maybe you are looking for

  • How do you change the apple id associated with an ipod?

    Have an apple ipod touch and just got an ipad.  want to link them; however, the apple id that is used on the ipod is also being used by another ipod.  I have a separate id for the ipad.  How can I change the one ipod to match the ipad?

  • Startup error message on Satellite M30-107

    I get the following message when trying to boot up: Windows could not start because the following file is missing or corrupt \windows\system32\config\system You can attempt to repair this file by starting windows setup using the original setup CD-ROM

  • Windows DNS - Active Directory record Load Failed

    Hello guys,  I'm in an environment with Windows Server 2012 R2 that have ADDS and DNS services deployed, have received event ID 4010 is as follows:  Event ID: 4010  Event Source: DNS  Event Log: DNS Server  Event Description: The DNS server was unabl

  • Tablet rejected as not in database

    I was trying to turn in my Ainol NovoElfII at store number 1782.  I was trying to get the promotion for the 50 dollar gift card and the 50 dollar samsung tab offer.  This is a full working android tablet and not an e reader or nook.  I was told at th

  • Isight not working on intelBased iMac core 2 duo osx 10.8.2

    in photobooth, facetime and skype... i got the  green light to come on... but  no camera is visasble in any application... this is my `1st mac and decided to try one out as im a PC type  person.... it does  show up in USB system profiler so it  sees