Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 12 of 12

Thread: Got problem calling method from inherited aggregation

  1. #1
    Junior Member
    Join Date
    Apr 2021
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Got problem calling method from inherited aggregation

    Hi,the following are my code. When I execute 'System.out.println(e.getBrowserInfo().getBrowser( )); ' in the last line of code in Webstat class. The result gives me 8 results of "Chrome". This is wrong as it is suppose to give answer as "Chrome" , "IE", "Chrome", "Firefox" ","Chrome","Safari","Chrome" & "IE". I have problem figuring out and please help on how to get the correct result.

     
        package problem;
     
        import java.io.BufferedReader;
        import java.io.BufferedWriter;
        import java.io.File;
        import java.io.FileNotFoundException;
        import java.io.FileReader;
        import java.io.FileWriter;
        import java.io.IOException;
        import java.security.Timestamp;
        import java.sql.Date;
        import java.text.DateFormat;
        import java.text.SimpleDateFormat;
        import java.time.LocalDate;
        import java.time.LocalDateTime;
        import java.time.chrono.ChronoLocalDateTime;
        import java.time.format.DateTimeFormatter;
        import java.util.ArrayList;
        import java.util.Arrays;
     
        import d1Assignment.Helper;
     
        public class WebStat {
        	private static int actionId = 100;
        	private static String browser;
        	private static double ConnectionSpeed;
        	private String[] webinfo; 
        	private  static ArrayList<SiteEntry> siteEntrydetails = new ArrayList<SiteEntry>();
        	private static ArrayList<SiteExit> siteExitdetails = new ArrayList<SiteExit>();
        	private static ArrayList<PageHop> pageHopdetails = new ArrayList<PageHop>();
     
        	public static void main(String[] args) {
        		WebStat wl = new WebStat();
        		wl.start();
        	}
     
     
     
        	private void start() {
     
     
        		int option = -1;
     
        		while (option != 6) {
        			updateArrayList();
        			menu();
        			option = Helper.readInt("Enter choice > ");
     
        			if (option == 1) {
        			//	AddNewSiteEntry();
        			} else if (option == 2) {
        			//	AddNewSiteExit();
        			}else if (option == 3) {
        			//	AddPageHop();
        			} else if (option == 4) {
        			//	ViewBrowseActions();
        			} 
        			else if (option == 6) {
        				System.out.println("Thank you for using our Service!");
        			}
        		  }	
        		}
        	private void menu() {
     
        		Helper.line(60, "=");
        		System.out.println("WELCOME TO MY WEB STAT PORTAL");
        		Helper.line(60, "=");
        		System.out.println("1. Add New Site Entry");
        		System.out.println("2. Add New Site Exit");
        		System.out.println("3. Add New Page Hop");
        		System.out.println("4. List Browse Actions by Date Range");
        		System.out.println("5. Export with Common Statistics Format");
        		System.out.println("6. Quit");
        	}
        	private  void updateArrayList() {
        		siteEntrydetails.clear();
        		siteExitdetails.clear();
        		pageHopdetails.clear();
        		try {
        			BufferedReader br = new BufferedReader(new FileReader(new File("visitdetails.txt"))); //read file from items.txt
        			String line = br.readLine();
     
        					while(line != null){
        						browser = "";
        						ConnectionSpeed = 0.00;
        						webinfo = line.split(",");
        						webinfo[0] = webinfo[0].trim();
        						actionId = Integer.parseInt(webinfo[0]);
     
        						webinfo[1] = webinfo[1].trim();
        						DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHH:mm");
        						LocalDateTime dateTime = LocalDateTime.parse(webinfo[1], formatter);
     
        						webinfo[6] = webinfo[6].trim();
        						double d = Double.parseDouble(webinfo[6]);
        						BrowseInfo browserInfo = new  BrowseInfo (webinfo[5],d);
        						//System.out.println(String.format("%-10d, %-10s, %-10s %-10s %-10s", actionId,dateTime,webinfo[2],browserInfo.getBrowser(),browserInfo.getconnectionSpeed()));
        						if(webinfo[2].trim().equalsIgnoreCase("entry")) {//save entries with entry in visitdetails.txt into ArrayList
        							SiteEntry SiteEntryObj = new SiteEntry(actionId,dateTime,webinfo[3],webinfo[4],browserInfo); 
        							siteEntrydetails.add(SiteEntryObj);
     
        							browser = "";
        							ConnectionSpeed = 0.00;
        						}
        						if(webinfo[2].trim().equalsIgnoreCase("exit")) {//save entries with exit in visitdetails.txt into ArrayList
        							SiteExit SiteExitObj = new SiteExit(actionId,dateTime,webinfo[3],webinfo[4],browserInfo); 
        							siteExitdetails.add(SiteExitObj);
        							browser = "";
        							ConnectionSpeed = 0.00;
     
        						}
        						if(webinfo[2].trim().equalsIgnoreCase("hop")) {//save entries with hop in visitdetails.txt into ArrayList
        							PageHop PageHopObj = new PageHop(actionId,dateTime,webinfo[3],webinfo[4],webinfo[5],d); 
        							pageHopdetails.add(PageHopObj);
        							browser = "";
        							ConnectionSpeed = 0.00;
        													}
        						line = br.readLine();
        					}
        			br.close();	
        		} catch (FileNotFoundException e) {
        			e.printStackTrace();
     
        		} catch (IOException io) {
        			io.printStackTrace();		
        		}
        		for(SiteEntry e: siteEntrydetails) {
     
        		    System.out.println(e.getBrowserInfo().getBrowser() ); //problem lies here
        		}
        	}
     
        }
    package problem;
     
    import java.time.LocalDateTime;
     
    public abstract class BrowseAction {
    	private int actionId;
    	private LocalDateTime actionDateTime;
    	private String page;
    	private static BrowseInfo browserInfo;
     
    	public BrowseAction(int actionId,LocalDateTime actionDateTime, String page, BrowseInfo browserInfo){
    		this.actionId = actionId;
    		this.actionDateTime = actionDateTime;
    		this.page = page;
    		this.browserInfo = browserInfo;
    	}
     
     
     
    	public int getActionId() {
    		return actionId;
    	}
    	public LocalDateTime getactionDateTime() {
    		return actionDateTime;
    	}
     
    	public  void setactionDateTime(LocalDateTime a) {
    		 actionDateTime = a;
    	}
    	public String getPage() {
    		return page;
    	}
    	public static BrowseInfo getBrowserInfo() {
    		return browserInfo;
    	}
     
    	public void display() {
     
    	}
    }
     
    package problem;
     
    public  class BrowseInfo {
    	private static String browser;
    	private  static double connectionSpeed;
     
    	public BrowseInfo(String browser, double connectionSpeed) {
    		this.browser = browser;
    		this.connectionSpeed = connectionSpeed;
    	}
     
    	public static String getBrowser() {
    		return browser;
    	}
     
    	public static double getconnectionSpeed() {
    		return connectionSpeed;
    	}
     
    }
    package problem;
     
    public interface CommonStat {
    	public String formatStat();
     
    }
     
    package problem;
     
    import java.util.*;
     
    public class Helper {
     
      @SuppressWarnings("resource")
      public static String readString(String prompt) {
        System.out.print(prompt);
        return new java.util.Scanner(System.in).nextLine();
      }
     
      public static int readInt(String prompt) {
        int input = 0;
        boolean valid = false;
        while (!valid) {
          try {
            input = Integer.parseInt(readString(prompt));
            valid = true;
          } catch (NumberFormatException e) {
            System.out.println("*** Please enter an integer ***");
          }
        }
        return input;
      }
     
      public static double readDouble(String prompt) {
        double input = 0;
        boolean valid = false;
        while (!valid) {
          try {
            input = Double.parseDouble(readString(prompt));
            valid = true;
          } catch (NumberFormatException e) {
            System.out.println("*** Please enter a double ***");
          }
        }
        return input;
      }
     
      public static float readFloat(String prompt) {
        float input = 0;
        boolean valid = false;
        while (!valid) {
          try {
            input = Float.parseFloat(readString(prompt));
            valid = true;
          } catch (NumberFormatException e) {
            System.out.println("*** Please enter a float ***");
          }
        }
        return input;
      }
     
      public static long readLong(String prompt) {
        long input = 0;
        boolean valid = false;
        while (!valid) {
          try {
            input = Long.parseLong(readString(prompt));
            valid = true;
          } catch (NumberFormatException e) {
            e.printStackTrace();
            System.out.println("*** Please enter a long ***");
          }
        }
        return input;
      }
     
      public static char readChar(String prompt) {
        char input = 0;
        boolean valid = false;
        while (!valid) {
          String temp = readString(prompt);
          if (temp.length() != 1) {
            System.out.println("*** Please enter a character ***");
          } else {
            input = temp.charAt(0);
            valid = true;
          }
        }
        return input;
      }
     
      public static boolean readBoolean(String prompt) {
        boolean valid = false;
        while (!valid) {
          String input = readString(prompt);
          if (input.equalsIgnoreCase("yes") || input.equalsIgnoreCase("y")
              || input.equalsIgnoreCase("true") || input.equalsIgnoreCase("t")) {
            return true;
          } else if (input.equalsIgnoreCase("no") || input.equalsIgnoreCase("n")
              || input.equalsIgnoreCase("false") || input.equalsIgnoreCase("f")) {
            return false;
          } else {
            System.out.println("*** Please enter Yes/No or True/False ***");
          }
        }
        return false;
      }
     
      public static Date readDate(String prompt) {
        java.util.Date date = null;
        boolean valid = false;
        while (!valid) {
          try {
            String input = readString(prompt).trim();
            if (input.matches("\\d\\d/\\d\\d/\\d\\d\\d\\d")) {
              int day = Integer.parseInt(input.substring(0, 2));
              int month = Integer.parseInt(input.substring(3, 5));
              int year = Integer.parseInt(input.substring(6, 10));
              java.util.Calendar cal = java.util.Calendar.getInstance();
              cal.setLenient(false);
              cal.set(year, month - 1, day, 0, 0, 0);
              date = cal.getTime();
              valid = true;
            } else {
              System.out.println("*** Please enter a date (DD/MM/YYYY) ***");
            }
          } catch (IllegalArgumentException e) {
            System.out.println("*** Please enter a date (DD/MM/YYYY) ***");
          }
        }
        return date;
      }
     
     
      private static String quit = "0";
     
      public static int getUserOption(String title, String[] menu) {
        displayMenu(title, menu);
        int choice = readInt("Enter Choice --> ");
        while (choice > menu.length || choice < 0) {
          choice = readInt("Invalid Choice, Re-enter --> ");
        }
        return choice;
      }
     
      private static void displayMenu(String title, String[] menu) {
        line(80, "=");
        System.out.println(title.toUpperCase());
        line(80, "-");
        for (int i = 0; i < menu.length; i++) {
          System.out.println("[" + (i + 1) + "] " + menu[i]);
        }
        System.out.println("[" + quit + "] Quit");
        line(80, "-");
      }
     
      public static void line(int len, String c) {
        System.out.println(String.format("%" + len + "s", " ").replaceAll(" ", c));
      }
     
      public static Date thisDate(int year, int month, int day) {
        Calendar cal = Calendar.getInstance();
        cal.setLenient(false);
        cal.set(year, month - 1, day, 0, 0, 0);
        return cal.getTime();
      }
     
      public static Date thisDate(int year, int month, int day, int hour, int min) {
        Calendar cal = Calendar.getInstance();
        cal.setLenient(false);
        cal.set(year, month - 1, day, hour, min, 0);
        return cal.getTime();
      }
     
      public static Date today() {
        Calendar cal = Calendar.getInstance();
        cal.setLenient(false);
        cal.setTime(new Date(System.currentTimeMillis()));
        cal.set(Calendar.HOUR_OF_DAY, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);
        return cal.getTime();
      }
     
      public static Date addDays(Date date, long days) {
        long time = date.getTime() + (days * 24 * 60 * 60 * 1000);
        return new Date(time);
      }
     
      public static Date setHourMinute(Date date, int hour, int min) {
        Calendar cal = Calendar.getInstance();
        cal.setLenient(false);
        cal.setTime(date);
        cal.set(Calendar.HOUR_OF_DAY, hour);
        cal.set(Calendar.MINUTE, min);
        cal.set(Calendar.SECOND, 0);
        return cal.getTime();
      }
     
      public static int getYear(Date date) {
        Calendar cal = Calendar.getInstance();
        cal.setLenient(false);
        cal.setTime(date);
        return cal.get(Calendar.YEAR);
      }
     
      public static int getMonth(Date date) {
        Calendar cal = Calendar.getInstance();
        cal.setLenient(false);
        cal.setTime(date);
        return cal.get(Calendar.MONTH) + 1;
      }
     
      public static int getDay(Date date) {
        Calendar cal = Calendar.getInstance();
        cal.setLenient(false);
        cal.setTime(date);
        return cal.get(Calendar.DAY_OF_MONTH);
      }
     
      public static Date now() {
        return new Date(System.currentTimeMillis());
      }
     
      public static int calcDayDifference(Date former, Date latter) {
        long diff = latter.getTime() - former.getTime();
        int days = (int) (diff / (24 * 60 * 60 * 1000));
        return days;
      }
     
      public static int calcYearDifference(Date former, Date latter) {
        int years = getYear(latter) - getYear(former);
     
        if (years > 0) {
          if ((getMonth(former) > getMonth(latter)) || 
              (getMonth(former) == getMonth(latter) && getDay(former) > getDay(latter))) {
            years -= 1;
          }
        } else if (years < 0) {
          if ((getMonth(former) < getMonth(latter)) || 
              (getMonth(former) == getMonth(latter) && getDay(former) < getDay(latter))) {
            years += 1;
          }
        }
        return years;
      }
     
      public static boolean sameDate(Date one, Date two) {
        return getDay(one) == getDay(two) && getMonth(one) == getMonth(two)
            && getYear(one) == getYear(two);
      }
    }
     
    package problem;
     
    import java.time.LocalDateTime;
     
    public class PageHop extends BrowseAction implements CommonStat{
     
    	private String fromPage;
    	private String output;
    	//private BrowseInfo browserInfo;
    	public PageHop ( int actionId,LocalDateTime actionDateTime,String fromPage, String page, String browser, double connectionspeed ){
    		super(actionId,actionDateTime,page, new BrowseInfo(browser,connectionspeed));
    		this.fromPage = fromPage;
     
     
    	}
    	public String getFromPage(){
    		return fromPage;
    	}
    	//public BrowseInfo getBrowserInfo() {
    	//	return browserInfo;
    	//}
     
     
    	public void display() {
    		System.out.println(String.format("%-10d ,%-20s ,%-10s ,%-30s ,%-30s ,%-10s ,%-10.2f ",getActionId(),getactionDateTime() ,"hop",getFromPage(), getPage(),getBrowserInfo().getBrowser(), getBrowserInfo().getconnectionSpeed()));
     
    	}
    	public String formatStat(){
    		output = String.format("%-10d ,%-20s ,%-10s ,%-30s ,%-30s ,%-10s ,%-10.2f \n",getActionId(),getactionDateTime() ,"hop",getFromPage(), getPage(),getBrowserInfo().getBrowser(), getBrowserInfo().getconnectionSpeed());
    		return output;
    	}
     
    }
     
    package problem;
     
    import java.time.LocalDateTime;
     
    public class SiteEntry extends  BrowseAction implements CommonStat{
    	private String fromExternalSite;
    	private String output;
     
    	public SiteEntry(int actionId,LocalDateTime actionDateTime,String fromExternalSite, String page, BrowseInfo browserInfo ) {
    		super(actionId,actionDateTime,page,  browserInfo); //this super statement must be above the this...statement
    		this.fromExternalSite = fromExternalSite;
     
    	}
     
    	public String getFromExternalSite() {
    		return fromExternalSite;
    	}
     
    	public void display() {
    		System.out.println(String.format("%-10d ,%-20s ,%-10s ,%-30s ,%-30s ,%-10s ,%-10.2f",super.getActionId(),super.getactionDateTime() ,"entry",fromExternalSite, super.getPage(),getBrowserInfo().getBrowser(),getBrowserInfo().getconnectionSpeed()));
    		//System.out.println(String.format("%-10d ,%-20s ,%-10s ,%-30s ,%-30s" ,super.getActionId(),super.getactionDateTime() ,"entry",fromExternalSite, super.getPage()));
    	}
    	public String formatStat(){
    		output = String.format("%-10d ,%-20s ,%-10s ,%-30s ,%-30s ,%-10s ,%-10.2f \n",super.getActionId(),super.getactionDateTime() ,"entry",fromExternalSite, super.getPage(),BrowseInfo.getBrowser(),BrowseInfo.getconnectionSpeed());
    		return output;
    	}
     
    }
     
    package problem;
     
    import java.time.LocalDateTime;
     
    public class SiteExit extends  BrowseAction{
    	private String toExternalSite;
    	private String output;
    	public SiteExit(int actionId,LocalDateTime actionDateTime, String page,String toExternalSite, BrowseInfo browserInfo) {
    		super(actionId,actionDateTime,page,  browserInfo); //this super statement must be above the this...statement
    		this.toExternalSite = toExternalSite;
     
    	}
     
    	public String getToExternalSite() {
    		return toExternalSite;
    	}
    	public void display() {
    		System.out.println(String.format("%-10d ,%-20s ,%-10s ,%-30s ,%-30s ,%-10s ,%-10.2f ",getActionId(),getactionDateTime() ,"exit", getPage(),getToExternalSite(),BrowseInfo.getBrowser(), BrowseInfo.getconnectionSpeed()));
    	}
    	public String formatStat(){
    		output = String.format("%-10d ,%-20s ,%-10s ,%-30s ,%-30s ,%-10s ,%-10.2f ",getActionId(),getactionDateTime() ,"exit", getPage(),getToExternalSite(),getBrowserInfo().getBrowser(), getBrowserInfo().getconnectionSpeed());
    		return output;
    	}
    }
    --------Output--------------------------------

    Chrome
    Chrome
    Chrome
    Chrome
    Chrome
    Chrome
    Chrome
    Chrome

    --------Output Ends--------------------------------

    The below are contents of visitdetails.txt :

    101 ,2021040903:07 ,entry ,Google ,home ,Chrome ,55.78
    102 ,2021040914:43 ,entry ,Google ,home ,IE ,99.11
    103 ,2021040915:26 ,entry ,www.soccernet.com.sg ,home ,Chrome ,34.45
    104 ,2021040915:41 ,entry ,Google ,home ,Firefox ,233.00
    105 ,2021040915:45 ,exit ,Join us ,Google ,Chrome ,99.11
    106 ,2021040917:37 ,exit ,Shop ,www.yahoo.new.com.sg ,Safari ,39.11
    107 ,2021040917:43 ,hop ,Join ,Shopping ,Firefox ,88.11
    108 ,2021040917:44 ,hop ,Check Out ,Join Us ,IE ,88.19
    109 ,2021040918:03 ,entry ,Google ,Home ,Chrome ,88.11
    110 ,2021040918:06 ,entry ,www.manutd.com ,home ,Safari ,99.11
    111 ,2021041001:07 ,entry ,www.Liverpool.com ,Find ,Chrome ,89.11
    112 ,2021041001:07 ,exit ,Shop ,www.mancity.com ,Firefox ,111.99
    113 ,2021041013:57 ,entry ,Google ,home ,IE ,71.77
    114 ,2021041013:58 ,exit ,Check Out ,Google ,Chrome ,38.19
    115 ,2021041014:00 ,hop ,Join Us ,www.maskgowhere.com.sg ,Safari ,55.89
    Last edited by Loh; April 12th, 2021 at 06:46 AM.

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Got problem calling method from inherited aggregation

    What packages are imported for this code? Can you add all the import statements?
    Also post all of the programs output.

    One big problem I see is too many of the variables are declared as static. That needs to be changed.


    Please edit your post and wrap your code with code tags:

    [code]
    **YOUR CODE GOES HERE**
    [/code]

    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Apr 2021
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Got problem calling method from inherited aggregation

    Thanks for your reply. I have edited the post accordingly.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Got problem calling method from inherited aggregation

    I have edited the post accordingly.
    Sorry, I do not see any code tags wrapping the code

    Please edit your post and wrap your code with code tags:

    [code]
    **YOUR CODE GOES HERE**
    [/code]

    to get highlighting and preserve formatting.

    http://www.java-forums.org/misc.php?do=bbcode#code


    Also you need to remove static from all the variables and most of the methods.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Apr 2021
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Got problem calling method from inherited aggregation

    Already input the code tag already. Thanks.

    I have removed static variable like browser and webinfo but the result is still the same.

    I need siteEntrydetails, siteExitdetails and pageHopdetails as static arraylist as these 3 arraylists are used in some methods in Webstat.
    Last edited by Loh; April 12th, 2021 at 01:14 AM.

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Got problem calling method from inherited aggregation

    There are several missing classes that prevent the code from being compiled and executed for testing.
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Junior Member
    Join Date
    Apr 2021
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Got problem calling method from inherited aggregation

    Sorry for overlooking that. I have included all the necessary classes already in the edited code. Thanks.

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Got problem calling method from inherited aggregation

    Those new classes have static variables that need to be changed so that they belong to the instance not to the class. In other words, each instance of the class has its own value.
    Remove the static part of the variables' declarations.
    If you don't understand my answer, don't ignore it, ask a question.

  9. #9
    Junior Member
    Join Date
    Apr 2021
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Got problem calling method from inherited aggregation

    I tried removing the static part of browser and connection speed , getbrowser () and getconnectionspeed(). But it still doesn't work. The complication is that BrowseAction which is parent class of SiteEntry, SiteExit and PageHop and BrowseAction is an abstract class which cannot be instantiated.

  10. #10
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Got problem calling method from inherited aggregation

    But it still doesn't work.
    Please explain and show the program's output.

    After removing all static variables here is the output I get:
    Running: java.exe WebStat

    Chrome
    IE
    Chrome
    Firefox
    Chrome
    Safari
    Chrome
    IE
    ================================================== ==========
    WELCOME TO MY WEB STAT PORTAL
    ================================================== ==========
    1. Add New Site Entry
    2. Add New Site Exit
    3. Add New Page Hop
    4. List Browse Actions by Date Range
    5. Export with Common Statistics Format
    6. Quit
    Enter choice >6
    Thank you for using our Service!

    0 error(s)
    If you don't understand my answer, don't ignore it, ask a question.

  11. #11
    Junior Member
    Join Date
    Apr 2021
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Got problem calling method from inherited aggregation

    Thanks alot for your help.

  12. #12
    Member
    Join Date
    Jul 2019
    Posts
    36
    Thanks
    2
    Thanked 4 Times in 4 Posts

    Default Re: Got problem calling method from inherited aggregation

    SiteEntry.browseInfo can't be static in

    class SiteEntry extends BrowseAction implements CommonStat {
        private static BrowseInfo browserInfo;

    for understand it try this simple example

    class SiteEntry {
    	static String browserInfo;
     
        SiteEntry(String br) {
        	browserInfo = br;
        }
    }
     
    public class Program {
    	public static void main(String[] args) {
    		SiteEntry s1 = new SiteEntry("Chrome");
    		SiteEntry s2 = new SiteEntry("FireFox");
    		SiteEntry s3 = new SiteEntry("Safari");
     
    		System.out.println( s1.browserInfo );
    		System.out.println( s2.browserInfo );
    		System.out.println( s3.browserInfo );
    	}
    }

Similar Threads

  1. Difficulty calling method in another method
    By Yearplanner in forum What's Wrong With My Code?
    Replies: 2
    Last Post: September 21st, 2019, 02:13 PM
  2. problem in calling a method
    By quasarLie in forum What's Wrong With My Code?
    Replies: 8
    Last Post: January 14th, 2018, 08:59 AM
  3. Carpet Calculator Problem using aggregation
    By gpelefty90 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 1st, 2011, 02:31 PM
  4. Replies: 2
    Last Post: February 28th, 2011, 10:51 AM
  5. Aggregation
    By pokuri in forum Object Oriented Programming
    Replies: 1
    Last Post: January 19th, 2011, 08:24 AM