TYPE CASTING ERROR

HI GURU's
I AM REQUIRED TO GENERATE USER ID AUTOMATICALLY STARTING FROM 0001, 0002, 0003 AND GOES ON INCREMENTING BY 1.
- I MADE USER ID FIELD OPTIONAL.
- THEN I CREATED AN ENTITY ADAPTER TO TRIGGER AT PRE INSERT EVENT, TAKING INITIAL VALUE AS 0000 IN A INTEGER VARIABLE.
- THEN OTHER VARIABLE STORES THE INCREMENTED VALUE OF INITIAL VALUE (INT ADD METHOD).
- THEN I MAPPED THE ADAPTER RETURN VARIABLE WITH THE ENTITY VALUE USER ID OF USER FORM.
WHEN I TRY TO CREATE USER IT SAY ERROR IN TYPE CASTING, OBVIOUSLY IT SHOULD SHOW BECAUSE I AM MAPPING INTEGER RETURN VARIABLE WITH THE STRING TYPE USER ID.
KINDLY SHOW ME THE WAY TO ACHIEVE THIS.
THANKS A LOT.

Have you tried searching this on Google.
See this link:
http://www.javadb.com/convert-an-int-value-to-string
In your Entity Adapter code, write few more lines from the method in the above link.
THEN I CREATED AN ENTITY ADAPTER TO TRIGGER AT PRE INSERT EVENT, TAKING INITIAL VALUE AS 0000 IN A INTEGER VARIABLE.
- THEN OTHER VARIABLE STORES THE INCREMENTED VALUE OF INITIAL VALUE (INT ADD METHOD).
- THEN I MAPPED THE ADAPTER RETURN VARIABLE WITH THE ENTITY VALUE USER ID OF USER FORM.

Similar Messages

  • CAST Not working for me - Arithmetic overflow error converting int to data type numeric - error

    GPM is DECIMAL(5,2)
    PRICE is DECIMAL(11,4)
    COST is DECIMAL(7,2)
    Trying to update the Gross Profit Margin % field and I keep getting the "Arithmetic overflow error converting int to data type numeric" error.
    UPDATE SMEMODETAIL SET SMD_GPM = (SMD_PRICE-SMD_COST) / SMD_PRICE * 100
    FROM SMEMODETAIL WHERE SMD_PRICE<>0 AND SMD_QUANTITY<>0
    Example record:
    SMD_PRICE    SMD_COST    GPM%
    1.8500            1.62                12.4324324324324300
    I added cast and I still get the error.
    How do I format to get this to work?
    Thanks!

    Hi GBerthume,
    The error is caused by some value such as 1000.01 of the expression (SMD_PRICE-SMD_COST) / SMD_PRICE * 100 exceeds the
    precision of the column(DECIMAL(5,2)). The example data doesn't cause the overflow error for the value of the expression is 12.43 which is in the scope of DECIMAL(5,2).
    USE TestDB
    CREATE TABLE SMEMODETAIL
    SMD_PRICE DECIMAL(11,4),
    SMD_COST DECIMAL(7,2),
    SMD_GPM DECIMAL(5,2)
    INSERT INTO SMEMODETAIL(SMD_PRICE,SMD_COST) SELECT 1.8500,1.62
    UPDATE SMEMODETAIL SET SMD_GPM = (SMD_PRICE-SMD_COST) / SMD_PRICE * 100
    FROM SMEMODETAIL WHERE SMD_PRICE<>0-- AND SMD_QUANTITY<>0
    SELECT * FROM SMEMODETAIL
    DROP TABLE SMEMODETAIL
    The solution of your case can be either scale the DECIMAL(5,2) or follow the suggestion in Scott_morris-ga's to check and fix your data.
    If you have any question, feel free to let me know.
    Eric Zhang
    TechNet Community Support

  • Could not type cast in java embedding

    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    DocumentBuilder db = dbf.newDocumentBuilder();
    org.xml.sax.InputSource in = (org.xml.sax.InputSource) getVariableData("Invoke_1_getRoutingAndFrameJumpers_OutputVariable","getRoutingAndFrameJumpersResponse");
    Document doc = db.parse(in);
    In the above code I am trying to type cast the variable getRoutingAndFrameJumpersResponse into org.xml.sax.InputSource so that i can parse.
    I am not getting any error during compilation
    but I am unable to type cast some run time error is coming in the line were I am type casting but I am not able to see the runtime error.
    How can I see the runtime error in java embedding, how to type cast a variable into xml so that I can parse it.

    Hi Arun,
    Could you try using the bpelx:rename extension in an assign activity enables a BPEL process to rename an element through use of XSD type casting.
    <bpel:assign>
    <bpelx:rename elementTo="QName1"? typeCastTo="QName2"?>
    <bpelx:target variable="ncname" part="ncname"? query="xpath_str" />
    </bpelx:rename>
    </bpel:assign>
    Cheers
    A

  • Cast error in java sound

    Hey, i got a little run-time error:
    Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: com.sun.media.sound.PortMixer$PortMixerPort
    the code segment it occurs at is here:
    case 0:
          targetDataLine1 = (TargetDataLine)mixer1.getLine(targetInfo);
          targetDataLine2 = targetDataLine1;
    }Some background info: I used getTargetLines() method of Mixer to obtain an arraylist of all the Line.Info objects (for targetLines) in a mixer, then I passed this into a GUI class, and made a vector to display in combo box. once user selects an item, it casts it back into Line.Info, and calls the mixer's "getLine()" method to retrieve the line. But I get the cast error. I know you can cast from Line to TargetDataLine (since TargetDataLine is a subinterface of Line) -- and I saw it on a tutorial, so I don't know what's wrong. Any help?
    If you need more info, just tell me.

    But still, the tutorial I looked at
    (http://java.sun.com/j2se/1.5.0/docs/guide/sound/progr
    ammer_guide/chapter3.html#113154)
    still showed it down-casting from a Line object to a
    TargetDataLine object.
    You need to understand the difference between a reference and an object. The object itself was a TargetDataLine object, otherwise the cast wouldn't have worked. The reference to it was of type Line.
    // obj is a reference of type Object. The object it points to is a String:
    Object obj = "I am a String";
    // Which explains why this works:
    String s = (String)obj;
    // and why this fails:
    Integer i = (Integer)obj;
    Not to mention, the java API says that the
    getLine(Line.Info) object returns an object of type
    Line.
    And I still don't understand why you can't cast from
    a superclass to a subclass. I know intuitively, it
    makes since, since not all RECTANGLES are SQAURES,
    but all SQUARES are RECTANGLES. But still, I know
    enough programming to remember numerous instances of
    casting Object as other classes....
    See above.
    Oh, and what does the $ symbol in
    com.sun.media.sound.PortMixer$PortMixerPort mean?It means that the the class PortMixerPort is an inner class (or nested class, I never remember the difference :-) in the class PortMixer.

  • Dynamic Type casting

    Can we dynamically type-cast an object reference passed to Object Clss to that specific class?
    Here is what I want to do.
    I am going to pass an object reference to a method, which has Object class as parameter to it, as shown below. Using getClass() or some other way, I want to dynamically typecast this reference to the original Class and call some method of this Class.
    void test (Object ref1){
    ((ref1.getClass())ref1).writeLog();
    By doing this, am I violating the basic Object Orineted rules?

    I mean, consider an hypothetical case (which is wrong
    from OO point of view) that there are suppose 10
    classes in my system. None of them related to each
    other, all are independent classes. But each one has a
    method called, writeLog(). Now I want to write one
    method which will be called by each of these classes
    (in some 11th class), which will have "Object" as a
    parameter. Now using the actual reference I want to
    call the corresponding writeLog() method.
    1 - Point out to management that the design is now officially broken.
    2 - Point out that if the design is not fixed then any solution that impliments the changes will cost more to maintain in the future and will likely lead to instabilities in the system (due to complexity.)
    3 - Implement one of the suggested solutions and make sure that you put in a lot of error checking and logging in the hacked solution.
    4 - Produce extensive documentation about the impact of changing any of the objects that you are relying on. Push it to anyone and everyone that might ever touch or even suggest changes to the code.
    Doing all of the above allows you to live stress free when the next revision breaks because someone didn't understand the implications of your hacked solution. You will be able to find the problem quickly and point out that it had nothing to do with your code but rather because someone else did not follow the complete documentation that you produced. And then when they complain that your solution was a hack you can point out that you explained that previously as well.

  • Unbounded wildcard type: type mismatch error

    I have a problem with Generics which to me seems to be caused by type erasure and necessary reification, but I can't find a solution.
    In order to keep the problem simple I've removed all unnecessary functions from the code and just made sure it still compiles - the only method that does not compile (and kept its whole code) is the method processContents() that causes my problem.
    I hope that the code is self-explanatory enough without comments.
    public interface Iterator<T> {
         public T next();
         public boolean hasNext();
    public interface FunctionInterface<T> {
         T apply(T argument);
    public class DataStructure<T> {
         private T content;
         public DataStructure(T content) {
              this.content = content;
         public T get() {
              return content;
         public Iterator<DataStructure<T>> contents() {
              return new Iterator<DataStructure<T>>() {
                   @Override
                   public boolean hasNext() {
                        return false;
                   @Override
                   public DataStructure<T> next() {
                        return null;
    }The problem is caused in the methode processContents() of the methode SubDataStructure, a sub-class of DataStructure.
    public class SubDataStructure<T extends FunctionInterface<? super T>> extends
              DataStructure<T> implements FunctionInterface<SubDataStructure<T>> {
         public SubDataStructure(T content) {
              super(content);
         public T processContents() {
              Iterator<DataStructure<T>> iter = contents();
              T value = get();
              while (iter.hasNext()) {
                   T otherValue = iter.next().get();
                   // following line causes ERROR: Type mismatch: cannot convert from
                   // capture#1-of ? super T to T ReducedDataStructure.java
                   value = value.apply(otherValue);
              return this.get();
         @Override
         public SubDataStructure<T> apply(SubDataStructure<T> argument) {
              // arbitrary action
              return argument;
    }As you see the commented line causes an error saying "Type mismatch: cannot convert from capture#1-of ? super T to T ReducedDataStructure.java" - from my understanding the type should be correct but got lost at compile-time, but would have to be restored at run-time. If so, a type-cast should solve the problem, but I'd prefer to find a clean solution without unchecked casts.
    I've tried to find an answer in various books and the linked FAQ, but haven't found it yet - I admit that after a few hours of trying I got a bit frustrated, so I hope that this is a more common problem to developers and that somebody might be able to help. Any suggestions how do solve this problem? I'd be grateful for your answers.
    Bob
    Edited by: RobertSingleton on Nov 23, 2009 2:17 PM
    Edited by: RobertSingleton on Nov 23, 2009 2:21 PM

    RobertSingleton wrote:
    jtahlborn wrote:
    you have defined T to have a lower bound of "FunctionInterface<? super T>", value is of the type T, therefore the return type of value.apply (which comes from FunctionInterface) is "? super T". a value of "? super T" returned from the "apply" method cannot be re-assigned to "value", which has type T.Thanks, but I understood it so far. The question to me is, whether it is possible to solve the problem as shown here.
    are you sure you don't want the class typedef to be "T extends FunctionInterface<? extends T>"?Yes, but would you have other suggestions? DataStructure manages Objects, SubDataStructure adds a few new methods, FunctionInterface is an Interface like Comparable. Maybe that's a bit too general to see whether the current solution is appropriate or not. But no matter how the a better solution would look like, I'd be very curious how to solve the problem in its current settings, since I'm positive I could apply the solution in the future to different problems with the same cause.the problem is that you have defined FunctionInterface in this case to return anything up to Object (? super T). "super" is good for saying "give me an object which can handle this type or any of its parent types". it's generally not so good for a return type, as you are essentially saying "i can return anything here". you want to repeatedly apply FunctionInterface, but your definition allows you to return something which may not implement FunctionInterface. so, you code cannot work with your current definitions. without having a better understanding of what you are trying to do, i can't really put forward any meaningful suggestions for fixing the code.

  • Field symbols - casting error

    Hi,
       I created a table dynamically and assigned it to field symbol. Now i want to write the contents of the internal table to a flat file in app server. Here is what i am doing.
    parameters: p_table(30) type c default 'PA0008',
                p_file LIKE RLGRAP-FILENAME default '/usr/sap/tmp/test.txt'.         " Path to save files to
    FIELD-SYMBOLS: <w_table> type standard table,
                   <w_wa>   TYPE any,
                   <w_field> type any.
    DATA: w_dyn_wa type ref to data,
          w_dyn_table type ref to data.
    CREATE DATA w_dyn_wa TYPE (p_table). "Suitable work area
    ASSIGN w_dyn_wa->* TO <w_wa>.
    create data w_dyn_table type standard table of (p_table).
    assign w_dyn_table->* to <w_table>.
    data w_dyn_data(5000) type c.
    SELECT * FROM (p_table) INTO table <w_table> where endda >= sy-datum.
    Data: w_temp type string.
    OPEN DATASET p_file FOR OUTPUT IN TEXT MODE encoding default.
    IF SY-SUBRC = 0.
      loop at <w_table> into <w_wa>.
      w_temp = ''.
        do.
          assign component sy-index of structure <w_wa> to <w_field>.
          if sy-subrc <> 0.
            exit.
          endif.
          concatenate w_temp <w_field> into w_temp respecting blanks.
          if sy-index = 1.
            transfer '' to p_file.
          endif.
         transfer <w_field> to p_file no end of line.
        enddo.
       transfer w_temp to p_file no end of line.
       write:/ w_temp.
      endloop.
    endif.
    close dataset p_file.
    when i run the program with PA0008 i am getting a casting error "Object not char like". How do i get rid of this error?. I tried moving the contents of field symbol to a string and appending it. It worked, but i lost the exact formatting of data in the file. In other words, it got rid of extra blanks. I need exact structure of internal table in the file.
    Thanks,
    Sandeep
    Thanks,
    Sandeep

    Hi
    Have u tried to use MOVE statament instead of CONCATENATE?
    do.
    assign component sy-index of structure <w_wa> to <w_field>.
    if sy-subrc <> 0.
    exit.
    endif.
    DESCRIBE FIELD <W_FIELD> LENGTH V_LEN.
    MOVE <W_FIELD> TO w_temp+V_OFFSET(V_LEN).
    V_OFFSERT = V_OFFSET + V_LEN.
    Max

  • Type cast exception

    Hi Guys,
    I am pretty new at generics and have started reading all material available online. Shown below is the API that I am using
    package api;
    public interface CS<C extends MyConfig> extends S {
    package api;
    public interface MyConfig {
    package api;
    public interface MySession {     
         public <C extends MyConfig, T extends ResourceContainer<? extends C>>
         T createContainer(CS<C> aPredefinedConfig);
    package api;
    public interface NC extends ResourceContainer<NCC>  {
    package api;
    public interface NCC extends MyConfig {
    package api;
    import java.io.Serializable;
    public interface ResourceContainer <T extends MyConfig> extends Serializable {
    package api;
    public interface S {
         public abstract boolean equals(Object other);
         public abstract int hashCode();
         public abstract String toString();
    }And below is my implementation
    package impl;
    import api.NC;
    public class NCImpl implements NC {
    package impl;
    import api.CS;
    import api.MyConfig;
    import api.MySession;
    import api.ResourceContainer;
    public class MySessionImpl implements MySession {
         public <C extends MyConfig, T extends ResourceContainer<? extends C>> T createContainer(
                   CS<C> predefinedConfig) {
              NCImpl ncimpl = new NCImpl();
              return ncimpl; //Error Type mismatch: cannot convert from NCImpl to T
    }As shown above I get error at line 'return ncimpl' But NCImpl implements the NC which extends ResourceContainer<NCC> so shouldn't it be capable of Type casting to T or I am missing something.
    Thanks a lot for your response in advance

    continuation of stack trace .................
    [INFO] ------------------------------------------------------------------------
    [ERROR] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Compilation failure
    /home/abhayani/workarea/eclipse/workspace/workspace-2.x/GenericsTest/impl/src/main/java/impl/MySessionImpl.java:[16,13] inconvertible types
    found : impl.NCImpl
    required: T
    /home/abhayani/workarea/eclipse/workspace/workspace-2.x/GenericsTest/impl/src/main/java/impl/MySessionImpl.java:[16,13] inconvertible types
    found : impl.NCImpl
    required: T
    [INFO] ------------------------------------------------------------------------
    [INFO] Trace
    org.apache.maven.BuildFailureException: Compilation failure
    /home/abhayani/workarea/eclipse/workspace/workspace-2.x/GenericsTest/impl/src/main/java/impl/MySessionImpl.java:[16,13] inconvertible types
    found : impl.NCImpl
    required: T
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:579)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:499)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:478)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:330)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:291)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:142)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:287)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
    at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
    at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
    Caused by: org.apache.maven.plugin.CompilationFailureException: Compilation failure
    /home/abhayani/workarea/eclipse/workspace/workspace-2.x/GenericsTest/impl/src/main/java/impl/MySessionImpl.java:[16,13] inconvertible types
    found : impl.NCImpl
    required: T
    at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:516)
    at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:114)
    at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:451)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:558)
    ... 16 more
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 5 seconds
    [INFO] Finished at: Thu Feb 12 10:39:43 IST 2009
    [INFO] Final Memory: 14M/81M
    [INFO] ------------------------------------------------------------------------
    [abhayani@localhost GenericsTest]$

  • Why we use type casting  ' ?='

    Hii Team
    sample code for fetching the input value from search view which is connected to btq1order contextnode
    DATA : lr_qs TYPE REF TO cl_crm_bol_dquery_service,
           lr_qr TYPE REF TO if_bol_bo_col,
    lr_qs ?= me->typed_context->btq1order->collection_wrapper->get_current( ).
    lr_qr = lr_qs->get_query_result( ).
    I am new to SAP CRM .while understanding the code i got stuck in one problem that ,
    1.what is the main purpose behind
    TYPE CASTING ie;  '?='
    2.what happens if we write ?=  becoz if we write  '='  instead of  '?='  the system thows an error.
    3.when to use this operator ?= and when we cannot use ?
    It is used almost every where in BOL coding .please help me  by giving complete explaination with an example if possible.
    Thanks in Advance

    Hi Abhishek,
    Please check returning parameter type for get_current_dquery() method. In case returning type is mutually convertible then you don't have to use type casting.
    But in case where you are taking results in some other type where results are compatible but with different structure then you use type casting.
    best example would be cl_crm_bol_entity and if_bol_bo_property_access. Here property access is an interface to class and hence we use type casting.
    Please refer to:
    type casting
    You can find more documentation on internet if you search for type casting.
    Regards,
    BJ

  • Type casting of primitive types

    Hi,
    I have two pieces of code. The type casting between them is strange.
    1st snippet
    int i =100;
    byte b = i;This gives an precision error. where as this is allowed
    final int i =100;
    byte b = i;Pls explain as to why is this happening.
    Regards,
    Anand

    The compiler sees that the value is a constant, and that it can't change. And it can therefore validate that the value is within the valid range for a byte.
    /Kaj

  • Type casting for properties accessed in COM Object

    I have a com object that I need to access which provides my a
    list of addresses in an Array. The object give me a property that
    has a count for the number of addresses and then I have a loop that
    calls the property which contains the address details to get each
    individual address each time passing to the property the INDEX
    value on the loop.
    This errors out each time.
    The error I get is
    Error casting an object of type to an incompatible type.
    This usually indicates a programming error in Java, although it
    could also mean you have tried to use a foreign object in a
    different way than it was designed.
    It appears the the variable type of the index is not
    compatible with the property of the component(which is an int).
    IS there some way to type cast the variable used as the index
    for CFLOOP to that of an INT?

    You can try to use the JavaCast("int", myValue) function. It
    works great for Java objects, but I'm not sure how well it will
    work for COM. Worth a try, I guess.
    In your case it would be something like:
    <cfobject type="COM" context="INPROC" action="create"
    name="MR" class="DLLNAME">
    <cfloop from="1" to="#AddressCount#" index="i">
    <cfset VDname = mr.vdsname(JavaCast("int", i))>
    <cfset VDaddress = mr.vdsaddress(JavaCast("int", i))#>
    <cfset VDXML = mr.VDSXML(JavaCast("int", i))>
    </cfloop>

  • Type casting problem in the JSP

    Hi,
    I am type casting an Object variable to a interface Variable. I am not getting any error if i have the same code in the servlet but i am getting ClassCast Exception if i have the same code in the Scriplets part of the JSP.
    The code is as follows
    String strKey = " SomeString";
    Context context = new InitialContext();
    java.lang.Object obj = null;
         obj = context.lookup(strKey);
         ContentBroker objCB = null;
         objCB = (ContentBroker)obj; // Error is happening here
    ContentBroker is an inteface.
    I have included the jar files of ContentBroker in the classpath.
    Can anyone please tell me how to eliminate this error.?
    thanks in advance,
    Saravanan

    In that case it's a classloader issue.
    Since the object is bound in the context, I assume that you have made the class available to your server, and you have the class in WEB-INF/classes or in a jar inside WEB-INF/lib.
    Since they're being loaded by two different classloaders, the classes are seen as different by the JVM, thus the ClassCastException.
    Try removing the class from the web-app and let us know what happens.
    BTW. Which servlet container are you using?

  • Parent..child clas type casting???

    Hi All,
    I have a query, please have a look:
    I have a parent class :: parent (getting compiled well , it's a simple class only)
    I have a child class :: child
    please see the code for child class below:
    public class child extends parent
       public static void main(String args[])
          //child c = new mainClass();   //STATEMENT1. This gives comiplation error for incompatible types.
          child c = (child) new mainClass(); //STATEMENT2. this statement works fine
    }Is there any reason why typecasting does not occur in statement 1 where as it is working fine in statement 2?
    I am intending to do the same thing in both statement 1 and 2.
    Any specific reason why implicit type casting does not work?
    Please comment.
    TIA
    Ayusman

    If mainclass is not a subclass of child, then you can't assign it as in #1.
    #2 will work at compile time if the compiler cannot be sure that a reference to a mainclas is cannot be a reference to a child.
    If #1 fails and #2 compiles, than I can only assume that child extends mainClass. In both cases, all the compiler knows about the new is that is returns a reference to a mainClass.
    #1 is allowed only if all mainClasses are childs--that is, if mainClass extends child.
    #2 is allowed at compile time if and only if a reference to a mainClass could be a reference to child. In this case that would have to mean that child extends mainClass. The compiler doesn't know that you're pointing at an object that is only a mainClass. All it knows is that it's a mainClass or one of it's subclasses. However, since it is in fact only a mainClass and not a child, you will get a ClassCastException at runtime.

  • Why do we require Type Casting?

    Hi,
    In short can you guys share your experience and expalin me why and when do we require type casting of objetcs.I would appericiate if i get a simple application as an example.
    regards
    Vicky

    Hi,
    In short can you guys share your experience and
    nd expalin me why and when do we require type casting
    of objetcs.I would appericiate if i get a simple
    application as an example.
    regards
    VickyWhy do you need this again?
    Well, really you need type casting because you want to be able to check for errors at compile time. You actually don't need any type casting if you just wait to link all your code at runtime.
    Normally your function calls are checked vs the real 'type' at compile time to see if you are calling the function with the proper types and number of arguments. same with returning. However, you don't have to do this, just look at any scripting language. All that is checked at runtime.
    Problems with not checking at compile time are mostly speed and corectness errors. The runtime might decide to call a different function then the one you wanted because at runtime a 'better' one was found. Of course now you would get a link error at runtime and the code would just not execute. There would be problems with overriding and hiding of functions, etc.
    Also, since you can't link ahead of time it takes longer to execute functions since you have to find them everytime they are called.
    The advantage is that you can be lazy about typing.
    Typecasting primitaves are a whole other problem. I'm not even going to go into that, but check out scripting languages for examples of autocasting primitives.

  • Type cast of BigInteger to Int

    Hi All,
       I am working on Email Web Service with Web dynpro.
    I am getting an error in type casting BigInterger(which was declared in WSDL) to Int. Java is not recognizing this BigInteger. Can any one help me??
    Regards,
    Theja

    Thejaswi,
    Where exactly this happens?
    I mean, if you can control this part of code why not to do:
    BigInteger bigInt = <...>;
    int int = bigInt.intValue();
    VS

Maybe you are looking for

  • No login available on ttys (systemd)

    Hello, I can no longer login to ttys (ctrl + alt + F1 - this is called a "tty" right?). If I switch to one of the ttys I can still read some bootup messages I think. The last one says [OK] listening on delayed shutdown socket No login prompt or blink

  • [SOLVED]Gnome 3.4 is not suspending when the lid is closed.

    Hey.. Since upgrading to gnome 3.4.1, my laptop does not suspend when the lid is closed. I have read this this thread without getting a clear answer... I have checked the setting in gnome tweak tool, and they are both set to "Suspend" The laptop has

  • Caching problem in Applets - Java Control Panel

    I have a problem of applets being cached in Java Control Panel. Is there a way in Java to stop caching applets programatically in the Java Control Panel. There is one way to stop caching files by unchecking "Keep Temporary Files on my Computer" under

  • Form Distribution Issues

    I have two related issues regarding the distribution function in Arobat 9.0. We have an order form with a "submit by email" button on it. Myself and a co-worker, Leon, are responsible for completing that form for each order. I created the form in Liv

  • Can we give  SAP ABAP CERTIFICATION exam from other than SAP TECHED

    Dear,        I busy with my project if i won't get chance to attend the SAP TECHED can i  give SAP ABAP ASSOCIATE LEVEL CERTIFICATION in any other way . i possible please tell me fee and process to attend the exam .