Casting or Generics, which is better?

Which is better for serialization <--> de-serialization?
public class MyClass {
private Object st;
public MyClass (Object what) { st = what; }
public Object get() {return st;}
out.writeObject(new MyClass("This is a test"));
Object ob =  in.readObject();
if (ob instanceof String) {
  Sting result = (String) ob;
}Or using Generics?
public static final byte STRING_TYPE = 0x01;
public class MyClass<T> {
private T st;
private byte type;
public MyClass ( byte type, T what ) { st = what; this.type = type; }
public T get() {return st;}
public byte getType() {return type;}
out.writeObject(new MyClass<String>(STRING_TYPE,"This is a test"));
MyClass<?> value =  (MyClass<?>) in.readObject()
if (value.getType() == STRING_VALUE) {
  MyClass<String> str = (MyClass<String>) value;
  Sting result = str.get();
}Both have unchecked casts (at least according to Eclipse), it is better to cast the generic or just use casts and not use generics? The latter is more complicated but allows more flexibility, but which method is correct?

CREATE TABLE `login` (
`username` varchar(40) DEFAULT NULL,
`password` varchar(40) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `amount` (
`amountid` int(11) NOT NULL,
`receiptid` int(11) DEFAULT NULL,
`loanid` int(11) DEFAULT NULL,
`amount` bigint(11) DEFAULT NULL,
`latefee` int(11) DEFAULT NULL,
`paymentid` int(11) DEFAULT NULL,
`pid` int(11) DEFAULT NULL,
PRIMARY KEY (`amountid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `applicationfee` (
`applicationfeeid` int(11) DEFAULT NULL,
`applicationamount` int(11) DEFAULT NULL,
`applicationfee` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `category` (
`categoryid` int(11) DEFAULT NULL,
`categoryname` varchar(40) DEFAULT NULL,
`categorydescription` varchar(500) DEFAULT NULL,
`cattype` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `commission` (
`commissionid` int(11) DEFAULT NULL,
`bussiness` int(11) DEFAULT NULL,
`commission` int(11) DEFAULT NULL,
`pid` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `customer` (
`cacno` int(11) NOT NULL DEFAULT '0',
`name` varchar(40) DEFAULT NULL,
`age` int(11) DEFAULT NULL,
`cphone` varchar(40) DEFAULT NULL,
`cmobile` varchar(40) DEFAULT NULL,
`caddress` varchar(500) DEFAULT NULL,
`cstatus` varchar(20) DEFAULT NULL,
`cphoto` longblob,
`pid` int(11) DEFAULT NULL,
PRIMARY KEY (`cacno`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `daybook` (
`closingbal` varchar(40) DEFAULT NULL,
`date` date DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `extraincome` (
`categoryid` int(11) NOT NULL,
`receiptid` int(11) DEFAULT NULL,
`date` date DEFAULT NULL,
`amountid` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `employee` (
`empno` int(11) DEFAULT NULL,
`empname` varchar(40) DEFAULT NULL,
`age` int(11) DEFAULT NULL,
`sal` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `image` (
`id` int(11) DEFAULT NULL,
`image` blob
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `loan` (
`loanid` int(11) NOT NULL DEFAULT '0',
`loanamt` varchar(40) DEFAULT NULL,
`payableamount` double DEFAULT NULL,
`installment` int(11) DEFAULT NULL,
`payableinstallments` int(11) DEFAULT NULL,
`monthlyinstallment` varchar(20) DEFAULT NULL,
`surityname` varchar(20) DEFAULT NULL,
`applicationfeeid` int(11) DEFAULT NULL,
`interestrate` float DEFAULT NULL,
`issuedate` date DEFAULT NULL,
`duedate` date DEFAULT NULL,
`nextduedate` date DEFAULT NULL,
`cacno` int(11) DEFAULT NULL,
`cname` varchar(20) DEFAULT NULL,
`pid` int(11) DEFAULT NULL,
`interestamt` double DEFAULT NULL,
`pendingamt` float DEFAULT NULL,
PRIMARY KEY (`loanid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `md` (
`mdid` int(11) NOT NULL DEFAULT '0',
`mdname` varchar(40) DEFAULT NULL,
`mdphoto` varchar(100) DEFAULT NULL,
`mdphone` varchar(40) DEFAULT NULL,
`mdmobile` varchar(40) DEFAULT NULL,
`mdaddress` varchar(500) DEFAULT NULL,
PRIMARY KEY (`mdid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `partner` (
`pid` int(11) NOT NULL DEFAULT '0',
`pname` varchar(40) DEFAULT NULL,
`paddress` varchar(500) DEFAULT NULL,
`pphoto` varchar(100) DEFAULT NULL,
`pphone` varchar(40) DEFAULT NULL,
`pmobile` varchar(40) DEFAULT NULL,
`pstatus` varchar(20) DEFAULT NULL,
`mdid` int(11) DEFAULT NULL,
`mdname` varchar(40) DEFAULT NULL,
`date` date DEFAULT NULL,
`nextpaydate` date DEFAULT NULL,
PRIMARY KEY (`pid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `partnerinvested` (
`pid` int(11) DEFAULT NULL,
`pname` varchar(20) DEFAULT NULL,
`receiptid` int(11) DEFAULT NULL,
`date` date DEFAULT NULL,
`amountinvested` int(11) DEFAULT NULL,
`latefee` int(11) DEFAULT NULL,
`amountid` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `payments` (
`paymentid` int(11) NOT NULL,
`categoryid` int(11) DEFAULT NULL,
`particulars` varchar(100) DEFAULT NULL,
`amountid` int(11) DEFAULT NULL,
`paymentdate` date DEFAULT NULL,
PRIMARY KEY (`paymentid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `receipts` (
`receiptid` int(11) DEFAULT NULL,
`paiddate` date DEFAULT NULL,
`amountid` int(11) DEFAULT NULL,
`loanid` int(11) DEFAULT NULL,
`latefee` int(11) DEFAULT NULL,
`installment` int(11) DEFAULT NULL,
`cacno` int(11) DEFAULT NULL,
`cname` varchar(40) DEFAULT NULL,
`pid` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

Similar Messages

  • Cast a generic object

    Hi how do you cast a generic object.
    For example I have a class GenericModel which can be either a movie or a director however when I wish to print out any awards that either a director or a movie has, I need to cast a generic variable (gM) to either a movie or a director something like this ...
    try {
    GenericModel d = (Director) gM;
    } if that fails do this{
    GenericModel m = (Movie) gM;
    }catch (Exception e){
    Or any other way that works.
    most appreciated

    Huh? I don't see why you necessarily need to cast anything and certainly not to base types such as Director or Movie.
    Also, the "try and if it fails try something else' pattern can be grossly inefficient.
    I wish to print out any awards that either a director or a movie hasThen your Director and Movie objects both need a printAwards() method; they also need to be sub-classes of a common class (or implement a common interface) that has all the behaviors you want to be in common.
    If that common class is GenericModel, then you would merely do:
      gM.printAwards();If that common class is something else, lets call it FilmObject, then you would need to cast your gM object to execute printAwards(), as so:
    if ( gM instanceof FilmObject )
      ( (FilmObject) gM).printAward();
    }This is really more of a basic Java issue that has nothing to do with JDBC or transactions; if you have followup questions, please ask them in another forum, not here.

  • Which is better to use: BEx query or Web Application as an iView in portal?

    Hi gurus!
    Are there any experienced opinions, which is better - publish a BEx query in portal or publish a BEx Web Application in portal? Is it easier to alter the layout attributes etc. if I create a BEx Web Application first before publishing?
    What is the way of fixing for example filter item height if I publish BEx query in portal - is there a Web Application that it uses anyhow which I can fix? Or can I use in that case iView -properties in portal?
    Thankful for advice
    Sari

    ok, means i can use jsp:useBean tag for all my
    classes that are not actually bean. so it will be
    instantiated at run time and provide efficiency .No. Jsp:useBean is used for java bean components.
    >
    but when should i use import statement in my jsp and
    it happen at translation time so will it create any
    type of burden for my code if i import multiple
    classes.For non-java beans, you need to import the classes, period.
    It's not a burden, it's a necessity.

  • Which is better for performance Azure SQL Database or SQL Server in Azure VM?

    Hi,
    We are building an ASP.NET app that will be running on Microsoft Cloud which I think is the new name for Windows Azure. We're expecting this app to have many simultaneous users and want to make sure that we provide excellent performance to end users.
    Here are our main concerns/desires:
    Performance is paramount. Fast response times are very very important
    We want to have as little to do with platform maintenance as possible e.g. managing OS or SQL Server updates, etc.
    We are trying to use "out-of-the-box" standard features.
    With that said, which option would give us the best possible database performance: a SQL Server instance running in a VM on Azure or SQL Server Database as a fully managed service?
    Thanks, Sam

    hello,
    SQL Database using shared resources on the Microsft data centre. Microsoft balance the resource usage of SQL Database so that no one application continuously dominates any resource.You can try the 
    Premium Preview
    for Windows Azure SQL Database which offers better performance by guaranteeing a fixed amount of dedicated resources for a database.
    If you using SQL Server instance running in a VM, you control the operating system and database configuration. And the
    performance of the database depends on many factors such as the size of a virtual machine, and the configuration of the data disks.
    Reference:
    Choosing between SQL Server in Windows Azure VM & Windows Azure SQL Database
    Regards,
    Fanny Liu
    If you have any feedback on our support, please click here. 
    Fanny Liu
    TechNet Community Support

  • Which is better??????

    which is better?Dam really confused which speaker to buy??
    i currently have a creative m2600.but am not getting enough performance or that feel while watching movies like avatar,step up 3 etc......so am planning to buy a 5.1.......not planning but i have decided to buy a 5.1....so..
    which is better? the 6160 or 6060 or 6100.
    which of these will provide me relly great exprience while playing games and most importantly while whatching hd movies and while listening to music.......
    and other than this what i have to ask is...what is this "db" in speakers. i mean while looking at a speaker specs we can see it..like 65db,85db,75db..etc........
    and when i compared specs of the three speakers i mentioned above i saw that the 6160 has low "db"........why is that?

    The specs is just a guide, you won't be able to tell the slight difference in db using just your ears. Besides, it is just a comparison between the level of a music to the level of background noise, it does not necessary mean which speaker sounds better. If possible, please make a trip to your local electronics store and try out the speakers system yourself.

  • Which is better, Photoshop or Corel?

    Which is better, Photoshop or Corel? I am finding the best one to use for my website [link removed]. Let me know your opinion. Tks all.

    Thank you! I am trying to find the best one for the site [Link removed].
    I used to use Corel before, but now, I am trying to use Photoshop.
    Tk you anyway
    [Removed link]
    Message was edited by: sinious

  • Which is better software for brochures and PDF forms ? Photoshop or InDesign ?

    Which is better software for brochures and PDF forms ? Photoshop or InDesign ? and why ?

    If you are going to be making a lot of brochures, with photos, you probably want both. Photoshop to edit the photos, and InDesign to assemble and layout images with text.

  • Which is better an android or apple

    Which is better getting an android smart phone or an Apple I Phone?

    As the poster Horses 547 said its a matter of personal preference. However I own and use both. Printing via air print is smooth and easy on an iphone. Printing on a android phone is iffy and tedious and you will have to find an app to print since there is no native app to do so. I purchased http://www.printhand.com which costs around $12 from the app store. but it is in my opinion the best printing app out there for android. I use it on my android tablet as well and its great. This company is the maker of the print app on iphones.
    The iphone is a little harder to put your own ringtone on the device. However very easy from the Itunes you put on your computer and hook into.
    Another thing an iphone does is if you use their cloud service or pay for a song it is available on all your ios devices. Iphone, ipad, or ipod or up to five computers registered through itunes on those computers.
    Google play music also can sync with all your android devices.
    Iphone don't have external Micro SD card slots, so the storage on the phone is all you have.
    Iphones use imessage which does not count against your text allotment  to another iphone or ipad user. it send regular text to non iphone users.
    Another thing is Face Time but I found a better program called oovoo at http://www.oovoo.com or in the Google Play Store for free.
    Iphones are paper thin but I have an android that has a larger view area and is also paper thin and light. Depending on the android phone it may have a removable battery, whereas iphones are sealed as are some new androids. I have found the sound for music better on my iphone, and videos are crystal clear. Again on some better androids the music and video is comparable .
    There is really not many differences but it up to the user.
    One last good thing is iphones are updated via Apple, no long waits for OS updates like is done with Android devices, and android devices on Verizon.

  • Which is better for doing animation? Flash 4, 5, MX, CS, or others?

    Which is better for doing animation? Flash 4, 5, MX, CS, or
    others?
    I am used to using brush function more conveniently in Flash
    4 than the other versions I ve tried. However, Flash 4 doesn't have
    pen tool.
    Free News Reader
    http://put.hk
    http://put.hk/reader/forums.macromedia.com/macromedia.flash.html

    1Evan2Wing3 wrote:
    > Which is better for doing animation? Flash 4, 5, MX, CS,
    or others?
    >
    > I am used to using brush function more conveniently in
    Flash 4 than the other versions I ve tried. However, Flash 4
    doesn't have pen tool.
    all pretty identical tho I would go with cs, just because I
    like the GUI much
    more than other versions...
    Best Regards
    Urami
    "Never play Leap-Frog with a Unicorn."
    <urami>
    If you want to mail me - DO NOT LAUGH AT MY ADDRESS
    </urami>

  • Which is better for bulk message scenario in sap xi RFC or Proxy

    which is better for bulk message scenario in ( RFC or Proxy ) ?
    Edited by: prabhatxi on Aug 6, 2010 4:44 PM

    Proxy will alwaays be better option in this case, as it is adapter less framework, and communication happens directly with XI central integration engine. So it is always fast communication and gives good performance.
    But still you should consider other factors, you may consider using RFC as well, as sometime we go for RFC/IDOC as this are the standard interfaces already available rather than creating structure...
    May be you can share more info on what type/volume data are you planning to send via XI?
    Hope this cleart your doubt..
    Divyesh

  • Which is better - Add a dimension or create more members in an existing

    Which is better - Add a dimension or create more members in an existing dimension?
    We are trying to figure out which can give us better performance in terms of calculations and retrieving reports - to add another dimension (entity/country) or add about 500-800 more members in an existing location/division dimension?
    Thank you!

    If you have BSO cube i would recommend to add in the same dimension where as ASO you can add members in a new dimension. Adding a new dimension is like creating a new cube you have to change each and every single calc scripts,report scripts,FR reports,Webforms and your rule files .... all the dependencies has to be changed manually . I think 500 members in the exsting BSO dimension will not impact the calc or retrieval times that much .

  • Which is better for servers, Apache or Tomcat?

    Which is better for servers, Apache or Tomcat?

    For some reason that link I gave you isn't working right now, but it was today, weird. I would get Tomcat simple because sun uses it in its examples and recommends it. Here's sun's link then, it's probably more useful anyway. http://java.sun.com/products/jsp/

  • Which is better sockets/socketchannel why

    which is better java.io.Socket / java.nio.channel.SocketChannel

    Better for what? They both work. Sockets are simple but only support blocking operations. SocketChannels are about ten times as complex to use but they support non-blocking and multiplexed I/O and also various types of direct and mapped buffering so they can also imply less data movement.

  • Which is better for newbies?

    Which is better for newbies, Jgrasp or Netbeans? I need something that explains errors more thoroughly than Jgrasp.

    Here's my code with 3 errors. Now bear in mind that my program has compiled completely and ran correctly up to this method. All I'm trying to do with this method is get the average of all grades in a multi-array. I researched and found some code that was similar to what I needed to do but it's not working out yet. All other methods in my program work perfectly but I can't get this one to compile.
    public double getMean(int allGrades[][])
              int total = 0;
              for (int grade : allGrades)
              total += grade;
         System.out.println("Total is "+getMean(grades));     
              return total/allGrades.length;
    } // end class GradeBookGradebook.java:100: illegal start of type
              return total/allGrades.length;
              ^
    Gradebook.java:100: <identifier> expected
              return total/allGrades.length;
              ^
    Gradebook.java:100: <identifier> expected
              return total/allGrades.length;
              ^
    3 errors

  • Which is better?    Two Oracle user in one instance OR  in two instances?

    Which is better?
    I could not find any benchmark for number of instances per user
    in the same machine.
    suppose that you have two major Oracle user, from performance
    point of view it is better to make separate instances in same
    machine or keep these two users in the same instance.

    Hi.
    I understand that you will use oracle for two different
    applications on the same host.
    Each instance has its SGA and background processes. So, using
    two different schemas(users) in one instance you can share
    phisical memory between the applications. Concerning background
    processes, you can start as many of them as you wish, so it's
    not a problem. If you decided that one DBW is not enough, you
    could configure oracle to use two or more.
    best regards,
    Andrew

Maybe you are looking for

  • How do I make this button look better in GIF?

    I confess I am fairly new to Illustrator... but if you can point me in the right direction, it will be greatly appreciated. All I need to do is to create a GIF that looks as good as a SWF.  I have played with all the settings and I can't figure out h

  • Attempt to collect old CC debt? Scam?

    I received a call at work today from and Uknown on my caller ID. First I didn't answer, they kept calling. Finally I answered and he asked if I was who he was looking for and to verify my last 4 of social. I verified and he stated he was trying to de

  • Exporting figures to word from labview using activex??

    Does anybody know how to export figures into MS Word, XP edition from LabVIEW using activex. I am not using the report generation toolkit...dont have it....help wld be appreciated kuttu

  • Microsoft project 98 and oracle 8i

    Hello, I'm trying to save a project from MS project 98 into an oracle 8.1.6 database (located on an AIX Server). I installed Net8 on the client (NT4), the Oracle ODBC driver, and MDAC 2.5. The connexion test is Ok. When I tried to save the project in

  • STMS - Import Queue not updating

    Hi, I'm hoping for a little guidance to track down a problem. We have a simple 3 system configuration (DEV > QAS > PROD) and we're currently about 2 months away from going live with the Production box. However, the STMS import queue for Production ha