CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 69

Threaded View

  1. #1
    Join Date
    Dec 2013

    Still can not call my Subclass method returns. J2EE

    I am having problems returning and using my subclass method returns... I am trying to print out the results but am getting just the space allocation only. Any help will greatly appreciated.

    package contacts;
    import java.util.Scanner;
    import java.util.ArrayList;
    public class Contacts {
        public static void main(String[] args) 
            System.out.println("By enetering B for Business  or P for personal contact: ");
            System.out.println("Are you a Business Contact or Personal Contact?: ");
            //Storing the users input
            Scanner in = new Scanner(System.in);
            String cont = in.next();      
            if (cont.equals("P"))
                System.out.println("Please enter: ");
            else if (cont.equals("B"))
                 Business fno = new Business();
                 Business lno = new Business();
                 Business ado =  new Business();
                 Business pno = new Business();
                 Business emo = new Business();
                 Business jto = new Business();
                 Business orgo = new Business();
                System.out.println("Please choose either B for Business Contact or "
                        + "P as a Personal Contact as you picked an invalid entry.");
               // return;
    package contacts;
    abstract public class ContactInfo 
        public abstract String firstName();
        public abstract String lastName();
        public abstract String address();
        public abstract String phoneNumber();
        public abstract String eMail();      
    package contacts;
    import java.util.Scanner;
    public class Business extends ContactInfo 
        Scanner in = new Scanner(System.in);
        public String firstName()
            System.out.println("Please enter your First Name: ");
            String fName2 = in.next();
            return fName2;
        public String lastName()
            System.out.println("Please enter your Last Name: ");
            String lName2 = in.next();
            return lName2;
        public String address()
            System.out.println("Please enter your Address: ");
            String addre2 = in.next();
            return addre2;
        public String phoneNumber()
            System.out.println("Please enter Phone Number: ");
            String phoneNum2 = in.next();
            return phoneNum2;
        public String eMail()
            System.out.println("Please enter your Email Address: ");
            String eMailAdd2 = in.next();
            return eMailAdd2;
        public String jobTitle()
            System.out.println("Please enter your job title: ");
            String jobTit = in.next();
            return jobTit;
        public String organization()
            System.out.println("Please enter your organization: ");
            String organ = in.next();
            return organ;
    Last edited by BigDadd215; February 28th, 2014 at 03:29 AM.

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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.