Why assigning a subclass instance to a variable of type of superclass ?

Hi all,
What is the significance of assigning an instance of a subclass to a variable whose type is a superclass's type.
For eg. List list=new ArrayList();
If I do so is it possible to execute the methods of the subclass ?
regards
Anto Paul.

In addition, this is what polymorphism is all about:
abstract class Animal {
  String name;
  Animal(String name) {
    this.name = name;
  public abstract void voice();
class Dog extends Animal {
  Dog(String name) { super(name); }
  public void voice() {
    System.out.println(name+" barks");
class Cat extends Animal {
  Cat(String name) { super(name); }
  public void voice() {
    System.out.println(name+" miaows");
public class Polymorphism {
  public static void main(String args[]) {
    Animal[] animals = {
      new Dog("Fido"),
      new Cat("Felix")
    for (int i = 0; i < animals.length; i++) {
      animals.voice();
Here, we are looping through an array of Animals. In fact, these are concrete subclasses of the abstract Animal class. In this simple example, you can see from the code that the animals array contains a dog and a cat. But we could even extend this to read in an arbitrary Animal object that had been serialized into a file. At compile time, the exact class of the serialized animal would not be known. But polymorphism occurs at runtime to ensure the correct voice() method is called.
For the List, or Map example, conisder this:
public SomeClass {
  public HashMap map1 = new HashMap();  // this ties you to hashmap
  public Map map2 = new HashMap();      // this allows you to change Map implementation
  public void process(HashMap map) {}   // this ties you to hashmap
  public void process(Map map) {}       // this allows you to change Map implementation
}Suppose you use a HashMap for map2 to start with. But at some point in the future you would like to ensure your map is sorted. By specifying map2 to be a Map, you can change the implementation without having to modify each method call by simplying changing the initiliastion to be:
Map map2 = new TreeMap();Hope some of this helps :) Cheers, Neil

Similar Messages

  • Inheritance - can a subclass inherit an instance of a variable?

    Is it possible for a subclass to inherit an instance of a variable that is contained in a method in the superclass? I'm (still) having huge problem with a subclass (and potentially many other subclasses) that need to inherit an instance of a variable..
    SUPERCLASS
    ConnectionBean cb = new Connection();
    public void joinChat() {
    ...add stuff to cb
    cb.send( packet );
    }then the subclasses need to inherit the same state of this variable 'cb' how can this be done?
    Thanks :)

    It reads like:
    public class Connection {
        //Create new instance of ConnectionBean
        ConnectionBean cb = new ConnectionBean();   
        //Create new instance of PresenceBuilder
        PresenceBuilder pb = new PresenceBuilder();
        //Create new instance of Comms Class
        Comms cms = new Comms();
        //Create new instance of UserInfo
        UserInfo user = new UserInfo();
        public String username;
        public String server;
        public String resource;
        public Connection() {
        //Method to send initial XML stream to Jabber Server
        public void joinChat() {
            InetAddress inetaddress;
            try {
                cb.connect( inetaddress = InetAddress.getByName( user.getServer() ));
            catch( UnknownHostException unknownhostexception ) {
                Object aobj[] = {
                    "Cancel", "Retry"
                int i = JOptionPane.showOptionDialog(null, "Retry Server?", server +
                    ": Not Responding", -1, 2, null, aobj, aobj[1]);
                if( i == 1 ) {
                    joinChat();
                System.out.println( "Cannot resolve " + server + ":" + unknownhostexception.toString ());
                return;
            catch( IOException ioexception ) {
                Object aobj1[] = {
                    "Cancel", "Retry"
                int j = JOptionPane.showOptionDialog( null, "Cannot Connect to: " + server,
                    "Error Message",-1, 2, null, aobj1, aobj1[1] );
                if( j == 1 ) {
                    joinChat();
                System.out.println( "Cannot connect " + server);
                return;
            System.out.println( "Joined Edit Session" );
            logonUser();
        //Method to Logon user with Jabber Server
        public void logonUser() {
            InfoQueryBuilder iqb = new InfoQueryBuilder();
            InfoQuery iq;
            IQAuthBuilder iqAuthb = new IQAuthBuilder();
            iqb.setType( "set" );
            iqAuthb.setUsername( user.getUsername() );
            iqAuthb.setPassword( user.getPassword() );
            iqAuthb.setResource( user.getResource() );
            try {
                iqb.addExtension( iqAuthb.build());
            catch ( InstantiationException e ) {
                //Building failed
                System.out.println( "Fatal Error on Auth object build");
                System.out.println( e.toString ());
                System.exit(0);
            try {
                //Build the full InfoQuery packet
                iq =( InfoQuery )iqb.build();
            catch ( InstantiationException e) {
                //Building Failed
                System.out.println( "Fatal Error on IQ object build:");
                System.out.println( e.toString());
                return;
            cb.send( iq );
            //Show <show> value
            pb.setStateShow( "chat" );
            //Show presence to Jabber Server
            pb.setStatus( "available" );
            try {
                cb.send( pb.build());
                //Add PacketListeners
                cb.addPacketListener( cms );       
            catch ( InstantiationException e ) {
                System.out.println( "Fatal Error on Presence object build:" );
                System.out.println( e.toString());
                return;
        public ConnectionBean getConnectionBean() {
            return cb;
    }But I still cant access the 'cb' variable in subclasses with including this in the subclass constructor:
    subclassConstructor() {
       super();
       joinChat();
    but this makes it work in a different way that I wanted and doesnt allow me freedom for other subclasses..

  • Management Report - Cannot assign an empty string to host variable 10

    We ran a Management Report for the first time after completing the User/Role/Profile Full Sync and the user/Role/Profile Batch Risk Analysis.  The job failed with the following error:
    Oct 16, 2008 12:13:29 PM com.virsa.cc.xsys.bg.BatchRiskAnalysis runBkgMgmReport
    WARNING: Exception in Management Report Job: Cannot assign an empty string to host variable 10.
    com.sap.sql.log.OpenSQLException: Cannot assign an empty string to host variable 10.
    We are on GRC 5.3 support pack 4.  Has anybody encountered this error? What does host variable 10 refer to?

    I checked our USOBT_C table and we have a lot of empty values. If this is allowed to be empty in SAP and this is the table that is uploaded into CC, why would all the fields in CC tables then be defined as NOT NULL?  We suspect that since we had uploaded USOBT_C under 5.2 and if this had been an issue before, it may have been corrected when we upgraded to 5.3 but then the old data is still in our system. Is there an easy way to get around or correct this?
    Thanks.

  • Assigning a workflow instance ID

    Hi,
    I just want to know if it's possible to assign my own instance ID when instantiating
    a workflow.
    Thanks.

    I have the same question, and I would like to be able to get to
    the actual "label" as opposed to setting up a new process
    variable. It is not accessible in the dialog box.
    Thanks
    John
    "Kara Moscoe" <[email protected]> wrote:
    When you say "workflow ID", do you mean the system-generated instance
    ID, or
    do you mean the template definition ID -- or "label" -- that you define
    in
    the Template Definition properties dialog? (There is some confusion around
    these, for which a CR has been opened.)
    If it's the latter, you should simply be able to specify a workflow variable
    name, and specify that variable as the return variable in the Perform
    Business Operation action for the business operation in question. If
    you
    want to manually intervene during a running workflow to change a variable
    value, you can also use the Update variables function in the Workflow
    Variables dialog box, accessed from the Workflow Instances dialog.
    Kara
    Ronen Yaari <[email protected]> wrote in message
    news:[email protected]..
    hI All,
    How can I change a WLI2.0 workflow ID after the workflow has started?
    The workflow is initialized via the WLI2.0 queue with an XML. I thencall
    a
    business operation
    that give me the value that I need to put in the workflow ID. How doI do
    that ?
    Thanxs,
    Ronen Yaari

  • Good practice to initalize all instance variables with type String to emptr

    Is it a good practice to initalize all instance variables with
    type String to emptry string?
    #1 approach:
    public class A
    { private String name = "";
    private String address ="";
    //etc...
    rather than
    #2 approach:
    public class A
    { private String name;
    private String address;
    //etc...
    When I read Java books, the examples don't usually do #1 approach.
    The problem is if we don't initialize to empty string, when we call
    the getter method of that instance variable, it will return null.
    Please advise. Thanks!!

    Please advise. Thanks!!It depends on your coding style. If you can avoid lots of checks for null Strings in the rest of the code then why not initialize to "".
    You have the same situation when a method returns an array. If you under circumstances return a null array reference then you have to always check for this special case, but if you return a zero length array instead you have no special case. All loops will just run 0 iterations and everything will work fine.
    So in general I guess the return of zero objects instead of null references really boils down to whether it simplicates the rest of your code by removing lots of extra checks for the special null case. This usage is especially favourable in the zero length array case. See Effective Java by Bloch, item 27.

  • Cannot assign an empty string to host variable 1

    Guys,
    I am getting the following problem while trying to create an entity bean., cmp field is not blank string yet I am getting the error. can you please help out?
    _33##0#0#Info##Plain###Remote Exception in Create: CreateA2iLogin: com.sap.engine.services.ejb.exceptions.BaseRemoteException: Exception in method a2i.beans.login.LoginHomeImpl0.create(java.lang.String).
         at a2i.beans.login.LoginHomeImpl0.create(LoginHomeImpl0.java:408)
         at a2i.beans.login.LoginHome_Stub.create(LoginHome_Stub.java:56)
         at com.nibco.a2i.beans.A2iLogin.createA2iLogin(A2iLogin.java:118)
         at com.nibco.a2i.beans.A2iLogin.<init>(A2iLogin.java:38)
         at com.nibco.training.servlet.SayHelloServlet.doPost(SayHelloServlet.java:121)
         at com.nibco.training.servlet.SayHelloServlet.doGet(SayHelloServlet.java:32)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:391)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:265)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:345)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:323)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:865)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:240)
         at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
         at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:148)
         at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:37)
         at com.sap.engine.core.cluster.impl6.session.UnorderedChannel$MessageRunner.run(UnorderedChannel.java:71)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:94)
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:162)
    Caused by: com.sap.engine.services.ejb.entity.ContainerException: Exception in method ejbStore().
         at com.sap.engine.services.ejb.entity.ContextFP.store(ContextFP.java:118)
         at com.sap.engine.services.ejb.entity.ContextFP.store0(ContextFP.java:103)
         at com.sap.engine.services.ejb.entity.Context.passivate(Context.java:235)
         at a2i.beans.login.LoginHomeImpl0.create(LoginHomeImpl0.java:401)
         ... 21 more
    Caused by: com.sap.engine.services.ejb.exceptions.BaseEJBException: SQLException while the data is being flushed. The persistent object is a2i.beans.login.LoginBean0Persistent.
         at com.sap.engine.services.ejb.entity.pm.UpdatablePersistent.ejbFlush(UpdatablePersistent.java:101)
         at com.sap.engine.services.ejb.entity.pm.TransactionContext.flushAll(TransactionContext.java:429)
         at com.sap.engine.services.ejb.entity.pm.TransactionContext.flush(TransactionContext.java:378)
         at com.sap.engine.services.ejb.entity.pm.TransactionContext.finishWork(TransactionContext.java:454)
         at a2i.beans.login.LoginBean0PM.ejbStore(LoginBean0PM.java:184)
         at com.sap.engine.services.ejb.entity.ContextFP.store(ContextFP.java:115)
         ... 24 more
    Caused by: com.sap.sql.log.OpenSQLException: Cannot assign an empty string to host variable 1.
         at com.sap.sql.log.Syslog.createAndLogOpenSQLException(Syslog.java:85)
         at com.sap.sql.log.Syslog.createAndLogOpenSQLException(Syslog.java:124)
         at com.sap.sql.jdbc.common.CommonPreparedStatement.setString(CommonPreparedStatement.java:584)
         at com.sap.engine.services.dbpool.wrappers.PreparedStatementWrapper.setString(PreparedStatementWrapper.java:341)
         at a2i.beans.login.LoginBean0Persistent.ejb_iInsert(LoginBean0Persistent.java:335)
         at com.sap.engine.services.ejb.entity.pm.UpdatablePersistent.ejbFlush(UpdatablePersistent.java:92)
         ... 29 more
    ; nested exception is:
         com.sap.engine.services.ejb.entity.ContainerException: Exception in method ejbStore().#
    #1.5#001143A7AF4000680000005900000F4C00040C3E95D97A60#1139362848402#System.out#sap.com/A2IEARCURR#System.out#Guest#0####edec5450984311da917b001143a7af40#SAPEngine_Application_Thread[impl:3]_33##0#0#Info##Plain###Success 2#

    Guys,
    I am getting the following problem while trying to create an entity bean., cmp field is not blank string yet I am getting the error. can you please help out?
    _33##0#0#Info##Plain###Remote Exception in Create: CreateA2iLogin: com.sap.engine.services.ejb.exceptions.BaseRemoteException: Exception in method a2i.beans.login.LoginHomeImpl0.create(java.lang.String).
         at a2i.beans.login.LoginHomeImpl0.create(LoginHomeImpl0.java:408)
         at a2i.beans.login.LoginHome_Stub.create(LoginHome_Stub.java:56)
         at com.nibco.a2i.beans.A2iLogin.createA2iLogin(A2iLogin.java:118)
         at com.nibco.a2i.beans.A2iLogin.<init>(A2iLogin.java:38)
         at com.nibco.training.servlet.SayHelloServlet.doPost(SayHelloServlet.java:121)
         at com.nibco.training.servlet.SayHelloServlet.doGet(SayHelloServlet.java:32)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:391)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:265)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:345)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:323)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:865)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:240)
         at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
         at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:148)
         at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:37)
         at com.sap.engine.core.cluster.impl6.session.UnorderedChannel$MessageRunner.run(UnorderedChannel.java:71)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:94)
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:162)
    Caused by: com.sap.engine.services.ejb.entity.ContainerException: Exception in method ejbStore().
         at com.sap.engine.services.ejb.entity.ContextFP.store(ContextFP.java:118)
         at com.sap.engine.services.ejb.entity.ContextFP.store0(ContextFP.java:103)
         at com.sap.engine.services.ejb.entity.Context.passivate(Context.java:235)
         at a2i.beans.login.LoginHomeImpl0.create(LoginHomeImpl0.java:401)
         ... 21 more
    Caused by: com.sap.engine.services.ejb.exceptions.BaseEJBException: SQLException while the data is being flushed. The persistent object is a2i.beans.login.LoginBean0Persistent.
         at com.sap.engine.services.ejb.entity.pm.UpdatablePersistent.ejbFlush(UpdatablePersistent.java:101)
         at com.sap.engine.services.ejb.entity.pm.TransactionContext.flushAll(TransactionContext.java:429)
         at com.sap.engine.services.ejb.entity.pm.TransactionContext.flush(TransactionContext.java:378)
         at com.sap.engine.services.ejb.entity.pm.TransactionContext.finishWork(TransactionContext.java:454)
         at a2i.beans.login.LoginBean0PM.ejbStore(LoginBean0PM.java:184)
         at com.sap.engine.services.ejb.entity.ContextFP.store(ContextFP.java:115)
         ... 24 more
    Caused by: com.sap.sql.log.OpenSQLException: Cannot assign an empty string to host variable 1.
         at com.sap.sql.log.Syslog.createAndLogOpenSQLException(Syslog.java:85)
         at com.sap.sql.log.Syslog.createAndLogOpenSQLException(Syslog.java:124)
         at com.sap.sql.jdbc.common.CommonPreparedStatement.setString(CommonPreparedStatement.java:584)
         at com.sap.engine.services.dbpool.wrappers.PreparedStatementWrapper.setString(PreparedStatementWrapper.java:341)
         at a2i.beans.login.LoginBean0Persistent.ejb_iInsert(LoginBean0Persistent.java:335)
         at com.sap.engine.services.ejb.entity.pm.UpdatablePersistent.ejbFlush(UpdatablePersistent.java:92)
         ... 29 more
    ; nested exception is:
         com.sap.engine.services.ejb.entity.ContainerException: Exception in method ejbStore().#
    #1.5#001143A7AF4000680000005900000F4C00040C3E95D97A60#1139362848402#System.out#sap.com/A2IEARCURR#System.out#Guest#0####edec5450984311da917b001143a7af40#SAPEngine_Application_Thread[impl:3]_33##0#0#Info##Plain###Success 2#

  • How to Assign a Field value to a Variable??

    Dear All,
    Kindly let me know, if <b>"HOW TO ASSIGN A FIELD VALUE TO A VARIABLE????"</b>
    Situation is, we have a Field (OBJK-TASER) in which 2 tables (SER01 & SER03) are stored. And we want to access names of the Tables which are there in the field(TASER) in  (OBJK) table  to a variable and then passing that variable to the sql query as a table name to get data accessed dynamicaly.

    try this
    select TASER from OBJK into table it_table.
    loop at it_table.
    select field1 field2 from (it_table-table) into table it_fields.
    endloop

  • Assigning a value to a substitute variable

    Hi, I would like to know if it is possible to assign a value to a substitute variable.
    This is what I'm doing:
    - Prompting user for input
    ACCEPT uom CHAR PROMPT 'Enter number of UOM system you would like: ' DEF '0'
    (displayed list of options are numbers 0-5)
    - Based on input, open corresponding file
    (start i:\utc\all\oracle\uom\uom_column_heading_&&uom..sql)
    Problem:
    - Default selection is 0, meaning use the CURRENT UOM system (a number, 1-5)
    - That being said, &&uom must be assigned a 1-5 value in order to open the file that corresponds to the CURRENT UOM system
    Let me know if any additional information is needed.
    Thanks!

    I apologize for the format. I tried to make it more legible, but was not able to. FYI: It appears to be easier to read in "Edit" view.
    Thanks, I tried the &&uom := your_function(); suggestion, but I am getting an error. It looks like the "value" of &&uom is being read in the assignment statement, not the variable name.
    I have copied the piece of the code, for your reference.
    ACCEPT uom CHAR PROMPT 'Enter number of UOM system you would like: ' DEF '0'
    DECLARE
    v_uom_sys_selection NUMBER;
    v_curr_uom_sys VARCHAR2 (50);
    v_uom_num NUMBER;
    BEGIN
    v_uom_sys_selection := to_number(&uom);
    v_curr_uom_sys := EG.GET_CURRENT_UOM();
    v_uom_num := eg.get_user_selected_uomnum(v_curr_uom_sys);
    &&uom := to_char(v_uom_num);
    dbms_output.put_line('v_uom_num = ' || v_uom_num);
    dbms_output.put_line('&&uom = ' || &&uom);
    END;
    --prompt "&&uom"
    start i:\utc\all\oracle\uom\uom_column_heading_&&uom..sql
    Below are the results I get when commenting out the &&uom := to_char(v_uom_num); line. NOTE: the "value" of &&uom = 0.
    v_uom_num = 1
    0 = 0
    If I leave that line in, I get the following error:
    PLS-00103: Encountered the symbol "0" when expecting one of the following:
    begin case declare end exit for goto if loop mod null pragma
    raise return select update while with <an identifier>
    <a double-quoted delimited-identifier> <a bind variable> <<
    close current delete fetch lock insert open rollback
    savepoint set sql execute commit forall merge pipe
    The symbol "<an identifier> was inserted before "0" to continue.
    Message was edited by:
    user449676

  • How can I assign a hard coded value to a variable of type OBJECT.

    Hi,
       I have to call the following method
                                      lc_action_execute->get_ref_object(
                                                            exporting
                                                                  io_appl_object = io_appl_object
                                                            importing
                                                                   ev_guid_ref    = lv_guid_ref.
    Now I have to hard code the io_appl_object variable (of type OBJECT) to test my application for the time being. How can I assign a value to the variable? Is there any way to do that?

    I wouldn't use WDR_CONTEXT_ATTR_VALUE_LISTGEN.  Use wdr_context_attr_value_list instead:
    data l_topics type zpm_main_topic_tbl.
      l_topics = wd_assist->read_all_topics( ).
      data lt_valueset type wdr_context_attr_value_list.
      field-symbols <wa_topic> like line of l_topics.
      field-symbols <wa_vs>  like line of lt_valueset.
      loop at l_topics assigning <wa_topic>.
        append initial line to lt_valueset assigning <wa_vs>.
        <wa_vs>-value = <wa_topic>-main_topic.
        <wa_vs>-text  = <wa_topic>-main_topic_desc.
      endloop.
      data lo_nd_meeting type ref to if_wd_context_node.
    * navigate from <CONTEXT> to <MEETING> via lead selection
      lo_nd_meeting = wd_context->get_child_node( name = wd_this->wdctx_meeting ).
      data lo_node_info type ref to if_wd_context_node_info.
      lo_node_info = lo_nd_meeting->get_node_info( ).
      lo_node_info->set_attribute_value_set(
         name = 'MAIN_TOPIC'
         value_set = lt_valueset ).

  • I want to assign the value of a Javascript variable to JSP Variable

    I want to assign the value of a Javascript variable to JSP Variable .. for example :
    <%
    Bla Bla Bla
    %>
    <script>
    var JavaScriptVariable="hello"
    </script>
    <%
    String JSPVariable=// The Value of JavaScriptVariable ;
    %>
    How can i do that ??
    Thanks

    >I want to assign the value of a Javascript variable to JSP Variable
    cannot be done.Friend try to understand concepts properly Javascript is always excuted by the browser @clientside where as JSPCode is executed Websever(ServletContainer) @serverside.Through you are combining JSP Code blocks(Tags,Expressions,scriptlets...) & javascript under a single page webserver can only identify what is their under JSP Code blocks.
    Hope this could be an appropriate answer for your question.
    However,you can as well submit a request by encoding your URL with request parameters and the submit to the page and then collect it using request.getParameter(name).
    But under a single context state it is not possible
    REGARDS,
    RaHuL

  • Why assign IP addresses to router/switch interfaces?

    I get why I would ever want to assign a IP address to a router or switch, for remote login and IP for hosts to reach it. But why assign IP addresses to the interfaces? Is it so the router/switch knows which port to send the packet out? Route summation? But I thought they do that through the routing table, like " that address is out this port".
    So why would we ever need to assign IP addresses to specific port interfaces?

    Disclaimer
    The Author of this posting offers the information contained within this posting without consideration and with the reader's understanding that there's no implied or expressed suitability or fitness for any purpose. Information provided is for informational purposes only and should not be construed as rendering professional advice of any kind. Usage of this posting's information is solely at reader's own risk.
    Liability Disclaimer
    In no event shall Author be liable for any damages whatsoever (including, without limitation, damages for loss of use, data or profit) arising out of the use or inability to use the posting's information even if Author has been advised of the possibility of such damage.
    Posting
    You normally assign IP addresses to L3 interfaces so other L3 devices have an IP address to forward traffic to.  (L2 IP address are generally only used for management.)
    Suppose you had Host (192.168.1.5/24) <> R1 <> R2 <> (192.168.2.8/24) Host, and you want the two hosts to intercommunicate.  How would you get this to work?
    You might started by providing interface IPs on the router interfaces facing the host, such as:
    Host (192.168.1.5/24) <> (192.168.1.1/24) R1 <> R2 (192.168.2.1/24) <> (192.168.2.8/24) Host
    You then configure "gateway" IPs on both hosts:
    Host (192.168.1.5/24 - GW 192.168.1.1) <> (192.168.1.1/24) R1 <> R2 (192.168.2.1/24) <> (192.168.2.8/24 - GW 192.168.2.1) Host
    Now each hosts "knows" to send all its off local subnet, traffic physically to the GW IP.  So, for example, if 192.168.1.5 want to sent to 192.168.2.8, it would forward the traffic to the GW IP, 192.168.1.1.  This is a example of why you want an IP on the router's L3 interface.
    Next we want R1 to forward the packet to R2, but it too needs a "next hop" IP address, so we assign addresses on the link between the two router, e.g.:
    Host (192.168.1.5/24 - GW 192.168.1.1) <> (192.168.1.1/24) R1 (192.168.3.1/24) <> (192.168.3.2/24) R2 (192.168.2.1/24) <> (192.168.2.8/24 - GW 192.168.2.1) Host
    R1 then needs to "know" where to send packets with an destination IP network of 192.168.2.0/24, in this case, it need to "know" to send the to IP 192.168.3.2.  When it does, R2, having and interface with 192.168.2.1, will also know 192.168.2.8 can be reached by sending the packet out that interface.
    Hopefully, the above will show why IP addresses on router L3 interfaces are needed.
    BTW, normally for the R1<>R2 link, you would assign a /30 or /31 network or you might use "unnumbered" interfaces (which "borrow" IPs from another interface).

  • Subclass instance not created during runtime

    Hi Experts,
    For an existing standard class a subclass was created and during runtime the me object reference points to the subclass name there by allowing the subclass additional/custom methods to be triggered.
    We have done service pack upgrade in the system and during runtime I find the subclass does not exist in the me object reference due to which the custom code in the subclass is not being called.
    How do I fix the above issue so that and subclass instance is created by the superclass during runtime?

    Hello Srinivas,
    I had put a breakpoint to debug in the subclass which was being invoked.
    In the new system where the service pack has been applied I have put breakpoint in the same method but the subclass method is not being called.
    The superclass method is being called. I'm sure after facing this problem(and solving it, of course) you'll have a better understanding of the 'polymorphic' behaviour of objects
    if the subclass inherits superclass the instance will be created automatically?
    NO!!!
    You must understand none of us has a crystal ball where we can gaze & find out the solution. If you want valuable responses please provide as much info as possible.
    BR,
    Suhas

  • How to assign a sql statement to a variable

    hey
    i am assigning a sql statement into a variable. But in sql statement where condition i am passing a variable, i am getting syntax error while processing this statement . Could please help me
    my code is like this
    sSql:='select id from SOURCES where name=' || vc_arr(i);
    Open C for sSql;
    ....

    If you use bind variables, you don't need the single quotes, and may avoid significant performance and security problems otherwise associated with dynamic SQL.
    sSql := 'select id from SOURCES where name = :some_value';
    OPEN C FOR sSql USING vc_arr(i);

  • When I try to File Save As on an .FLV movie, Firefox automatically changes the filetype to .mp4 while Chrome for instance retains the .FLV file type. I wanted to see why this is and how it can be fixed to work similarly to Chrome. Thanks.

    When I try to File > Save As on an .FLV movie, Firefox automatically changes the filetype to .mp4 while Chrome for instance retains the .FLV file type. I wanted to see why this is and how it can be fixed to work similarly to Chrome. Thanks.

    If that file is an FLV file then Firefox should save it as such and not change the file extension.
    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.org/kb/Safe+Mode
    See also:
    *http://kb.mozillazine.org/File_types_and_download_actions
    *https://support.mozilla.org/kb/Managing+file+types

  • Store a double into a variable of type int

    if I have a calculated value of type "double", and I would like to store it as an "int" in a variable of type "int".
    when i casted the double to int, seems it doesn't work.
    what should the command be?
    Thanks in advance!

    post your expression. I'd bet you aren't casting the value of assignment but rather a component of some computation.
    Something like this:
    double dub = 2.4;
    int returnvalue = (int)12/dub;as opposed to
    double dub=2.4;
    int returnvalue = (int)(12/dub);In the first entry, you would be casting 12 to an int and then dividing by a double and assigning the result to an int (returnvalue). Java will always try to expand precision to greatest common denominator, so the return value of the division will be a double (and hence the loss of precision assigning it to an int). The second entry properly casts the result of the whole expression as an int before assigning it to the int variable.

Maybe you are looking for

  • Regarding /564

    Hi All,   Where is the Wage Type /564(advance payment) formed in the Payroll Driver?

  • FI AR: Partial payments for open invoices

    Hi Experts, Greetings to all. We are using standerd data source 0FI_AR_04, Our data flow is Data source to DSO 0FIAR_O03 to CUBE 0FIAR_C03. Could you please tell me how to calculate due date analysis for partial payments. I checked the SAP note 52223

  • UCCX 7 - Change alert threshold for disk space

    We record every call into our UCCX 7 platform which makes my backups quite large. This causes an alert every night when the backups run from CRSAdmin stating that the server is running low on disk space and needs at least 40 GB free for B&R to run. I

  • No logs for iptables

    I had to install Arch again, but noticed soon one "fail", no firewall logs in /var/log/ no iptables, no firewall nothing. I use Arno's iptables configuring tool for my iptables. but there has been earlier iptables logs available. how to get them back

  • Setting RAW on a 60D

    When I try to set the camera to shoot RAW (in the Quality Menu) whether I use the main dial or the quick adjustment dial it is the JPEG setting that gets adjusted.  Unable to set the camera to shoot RAW