How can I determine what the type actually is?

I already posted this in "Java Programming", so I apologize if you are reading it for the second time.
I'm a CS3 student coding a data structure that uses generics. One of my methods has a possibility of much nicer results than the default if the type happens to be Character. I have been trying to figure out a way to test if the type is Character, but I can't find how to do this. Here are some things I've tried:
1. Stuff that works with variables but not types, like
if (E instanceof Character)        // does not compile
if (E extends Character)            // does not compile2. Something suggested by someone in "Java Programming":
if (E.class extends Character) // does not compile 3. Something along these lines:
E testOb;
if (testOb instanceof Character)The last one won't work because either I don't intialize testOb, in which case it won't compile, or I initialize it to null, in which case it will always evaluate to false anyway.
It seems there must be a way to do this. Anyone?

If your project is heavily concerned with Generics then you might want to have a look at this extremely comprehensive FAQ:
http://www.angelikalanger.com/GenericsFAQ/JavaGenericsFAQ.html
I learn best by reading technical documents from beginning to end so that's what I am doing (just about halfway through). It's nearly 500 pages in its PDF version so you may or may not want to do it my way.

Similar Messages

  • When I upgraded from v4 to v5 my bookmarks was lost. I do have the one that is in the firefox toolbar. Apparently I had a bookmarks add-on. V5 changed my browser how can I determine what the program was and if the bookmarks are still there?

    When I upgraded from v4 to v5 my bookmarks was lost. I do have the one that is in the firefox toolbar. Apparently I had a bookmarks add-on. V5 changed my browser how can I determine what the program was and if the bookmarks are still there?

    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance).
    *Do NOT click the Reset button on the Safe Mode start window or otherwise make changes.
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes
    Websites remembering you and automatically log you in is stored in a cookie.
    *Create an allow Cookie Exception to keep such a cookie, especially for secure websites and if cookies expire when Firefox is closed.
    *Tools > Options > Privacy > Cookies: Exceptions
    In case you are using "Clear history when Firefox closes":
    *do not clear Cookies
    *do not clear Site Preferences
    *Tools > Options > Privacy > Firefox will: "Use custom settings for history": [X] "Clear history when Firefox closes" > Settings
    *https://support.mozilla.org/kb/Clear+Recent+History
    Note that clearing "Site Preferences" clears all exceptions for cookies, images, pop-up windows, software installation, and passwords.
    Clearing cookies will remove all specified (selected) cookies including cookies that have an allow exception and cookies from plugins.

  • How can i determine what the most recent os my imac will run?

    How can i determine what the most recent os my iMac will run?
    Serial Number QP6*****VUW
    Processor 2.16 GHz Intel Core 2 Duo
    Currently running Version 10.5.8
    <Edited by Host>

    You CAN run 10.7, but I don't advise it, buy the 10.6.3 upgrade disk from the Apple Store online and then backup files off the machine and upgrade to 10.6.3., then Software Update to 10.6.8 would be the BEST option for your older hardware and it will run most all of your 10.5 software and be faster than 10.5 or 10.7.
    If you go to 10.7 it won't run nearly any of your 10.5 software and you will have to buy all new ones for a machine that's getting a little bit dated, near it's end of life stage. 10.7 will slow your machine down, especially with low RAM.
    http://roaringapps.com/apps:table
    At your machines stage, the hard drive is getting old, the vents are clogged up with dust and it's going to cost a bit to get the drive etc upgraded. You can if you wish, but 10.7 really needs more RAM (4GB) and a faster hard drive.
    But your still subjected to the video card going out etc.
    IMO upgrade to 10.6.8 and stay there until the wheels fall off, then buy a new 10.8 machine being released after this summer or 10.9 machine.
    Harden your Mac against malware attacks

  • How can I see what I'm actually video recording on iPad Air so that I don't include extra stuff at the borders of the image? It seems to automatically "zoom in" on the screen, but when I export the video, the picture isn't framed well.

    When I try to record a video on the Ipad Air, the screen automatically "zooms in" closer than when I'm taking a photo. So I frame the interview and record it. But when I export it to post it or edit it, I discover that only the screen was zoomed in, the camera wasn't, so I have all this extra stuff around the edges of my frame.
    I don't need to zoom in, but I do need to be able to see what I'm shooting--otherwise, as I'm videotaping, I'm guessing at my picture's framing. But every time I switch from photo to video mode, the screen "zooms in." How can I see what I'm actually recording?
    I've been searching for an answer for this for a while, but I can't find any responses to it! Thanks.

    Make sure that you allow pages to choose their colors and that you haven't enabled High Contrast in the Accessibility settings.
    *Firefox > Preferences > Content : Fonts & Colors > Colors : [X] "Allow pages to choose their own colors, instead of my selections above"
    See also:
    *http://kb.mozillazine.org/Images_or_animations_do_not_load
    *https://support.mozilla.org/kb/Images+or+animations+do+not+show

  • How can I determine what dns server the wifi client use within airport

    How can I determine what dns server the wifi client use within airport
    I want to use dns servers other then the one that airport extreme is using. For example I got the 172.16.1.1 (the default gateway - airport extreme), but I want to use the office dns servers, that are in a 10.x.x.x range.
    Is there a possibility?
    Thanks and happy eastern

    The Airport Extreme uses the DNS servers assigned by the network that it connects to. Is you Airport Extreme on the 10.x.x.x network? if it is then you are already using the 10.x.x.x DNS servers. Check your Airport Extreme with the Airport Utility and you will see in the Internet tab, the DNS servers used. The devices connecting to the Airport Extreme are assigned a DNS address of the Airport Extremes IP, In your case 172.16.1.1 but all DNS searches and resolution are done with the DNS servers you see in the Airport Extreme.
    If you want to use some other DNS then you can override in the Airport Extreme which will be used by all devices connecting too the Airport Extreme, Or you can edit the DNS address in each devices wireless settings.

  • I can't shut down my MacBook Pro.  I'm getting the following message: "The Finder can't quit because some operations are still in progress." How can I determine what is running?

    I can't shut down my MacBook Pro.  Each time I try, I get the following message: "The Finder can't quit because some operations are still in progress."  How can I determine what is running?

    Yea,
    I bought an original CRT iMac  two day's before  they were launched, which got the reseller into trouble, and had it replaced by APPLE.
    This was a great learning process for me dealing with the glitches. :-)
    I LOVE MAC. Now own 4 and on my 10th. in 15 years + 7  bought for family.
    Cheers,
    Tom

  • How can I determine what LLB a VI is being loaded from?

    I've been frustrated switching between versions when an application opens and suddenly can not find a VI which is being loaded from a LLB.  How can I determine what LLB (or other type of library) a VI is being loaded from ? 
    Is there a list of all libraries along with what VIs are included in them somewhere?
    Thanks, 
    Dave 

    In the context help, enable "Show Optional Terminals and Full Path ", then just hover over your VI, either on the diagram on in the hierarchy view.
    LabVIEW Champion . Do more with less code and in less time .

  • Async tcp client and server. How can I determine that the client or the server is no longer available?

    Hello. I would like to write async tcp client and server. I wrote this code but a have a problem, when I call the disconnect method on client or stop method on server. I can't identify that the client or the server is no longer connected.
    I thought I will get an exception if the client or the server is not available but this is not happening.
    private async void Process()
    try
    while (true)
    var data = await this.Receive();
    this.NewMessage.SafeInvoke(Encoding.ASCII.GetString(data));
    catch (Exception exception)
    How can I determine that the client or the server is no longer available?
    Server
    public class Server
    private readonly Dictionary<IPEndPoint, TcpClient> clients = new Dictionary<IPEndPoint, TcpClient>();
    private readonly List<CancellationTokenSource> cancellationTokens = new List<CancellationTokenSource>();
    private TcpListener tcpListener;
    private bool isStarted;
    public event Action<string> NewMessage;
    public async Task Start(int port)
    this.tcpListener = TcpListener.Create(port);
    this.tcpListener.Start();
    this.isStarted = true;
    while (this.isStarted)
    var tcpClient = await this.tcpListener.AcceptTcpClientAsync();
    var cts = new CancellationTokenSource();
    this.cancellationTokens.Add(cts);
    await Task.Factory.StartNew(() => this.Process(cts.Token, tcpClient), cts.Token, TaskCreationOptions.LongRunning, TaskScheduler.Default);
    public void Stop()
    this.isStarted = false;
    foreach (var cancellationTokenSource in this.cancellationTokens)
    cancellationTokenSource.Cancel();
    foreach (var tcpClient in this.clients.Values)
    tcpClient.GetStream().Close();
    tcpClient.Close();
    this.clients.Clear();
    public async Task SendMessage(string message, IPEndPoint endPoint)
    try
    var tcpClient = this.clients[endPoint];
    await this.Send(tcpClient.GetStream(), Encoding.ASCII.GetBytes(message));
    catch (Exception exception)
    private async Task Process(CancellationToken cancellationToken, TcpClient tcpClient)
    try
    var stream = tcpClient.GetStream();
    this.clients.Add((IPEndPoint)tcpClient.Client.RemoteEndPoint, tcpClient);
    while (!cancellationToken.IsCancellationRequested)
    var data = await this.Receive(stream);
    this.NewMessage.SafeInvoke(Encoding.ASCII.GetString(data));
    catch (Exception exception)
    private async Task Send(NetworkStream stream, byte[] buf)
    await stream.WriteAsync(BitConverter.GetBytes(buf.Length), 0, 4);
    await stream.WriteAsync(buf, 0, buf.Length);
    private async Task<byte[]> Receive(NetworkStream stream)
    var lengthBytes = new byte[4];
    await stream.ReadAsync(lengthBytes, 0, 4);
    var length = BitConverter.ToInt32(lengthBytes, 0);
    var buf = new byte[length];
    await stream.ReadAsync(buf, 0, buf.Length);
    return buf;
    Client
    public class Client
    private TcpClient tcpClient;
    private NetworkStream stream;
    public event Action<string> NewMessage;
    public async void Connect(string host, int port)
    try
    this.tcpClient = new TcpClient();
    await this.tcpClient.ConnectAsync(host, port);
    this.stream = this.tcpClient.GetStream();
    this.Process();
    catch (Exception exception)
    public void Disconnect()
    try
    this.stream.Close();
    this.tcpClient.Close();
    catch (Exception exception)
    public async void SendMessage(string message)
    try
    await this.Send(Encoding.ASCII.GetBytes(message));
    catch (Exception exception)
    private async void Process()
    try
    while (true)
    var data = await this.Receive();
    this.NewMessage.SafeInvoke(Encoding.ASCII.GetString(data));
    catch (Exception exception)
    private async Task Send(byte[] buf)
    await this.stream.WriteAsync(BitConverter.GetBytes(buf.Length), 0, 4);
    await this.stream.WriteAsync(buf, 0, buf.Length);
    private async Task<byte[]> Receive()
    var lengthBytes = new byte[4];
    await this.stream.ReadAsync(lengthBytes, 0, 4);
    var length = BitConverter.ToInt32(lengthBytes, 0);
    var buf = new byte[length];
    await this.stream.ReadAsync(buf, 0, buf.Length);
    return buf;

    Hi,
    Have you debug these two applications? Does it go into the catch exception block when you close the client or the server?
    According to my test, it will throw an exception when the client or the server is closed, just log the exception message in the catch block and then you'll get it:
    private async void Process()
    try
    while (true)
    var data = await this.Receive();
    this.NewMessage.Invoke(Encoding.ASCII.GetString(data));
    catch (Exception exception)
    Console.WriteLine(exception.Message);
    Unable to read data from the transport connection: An existing   connection was forcibly closed by the remote host.
    By the way, I don't know what the SafeInvoke method is, it may be an extension method, right? I used Invoke instead to test it.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How can I determine what computers are home sharing??

    How can I determine what computers are home sharing??

    Launch iTunes on the computers you're interested in. Check in the "Advanced" menu.
    If "Turn on Home Sharing" is listed as an option, the iTunes library that you have open is not Home Sharing.
    If "Turn off Home Sharing ([accountname]) is listed as an option, the iTunes library that you have open is Home Sharing.

  • Mac shut down due to problem; I rebooted fine. how do I determine what the problem was?

    mac shut down due to problem; I rebooted fine. how do I determine what the problem was?

    When shut down and rebooted, the Mac OS X does background maintenance on the system. That can solve minor issues.
    Beyond this, it is a good idea to run Disk Repair yourself just to make sure.
    Reboot with the option key held down. On the screen that comes up select the Recovery disk icon and Continue.
    On the next screen Clcik Disk Utility and Continue.
    In DU, in the list on the left select the drive to be repaired - click the item that is indented to the right, not an an item whose name starts on the far left.
    Click First Aid, then Repair Disk.
    After that is done, quit DU and restart as usual.

  • I've got an old I-phone.  How can I determine what model it is?  3 or 4.

    I've got an old I-phone.  How can I determine what model it is?  3 or 4.

    Append the last three characters of its serial number to http://www.everymac.com/ultimate-mac-lookup/?search_keywords= and load the page.
    (104117)

  • How can I determine what computers are authorized on my iTunes account?

    How can I determine what computers have been authorized on my iTunes account?  I've reached my limit and now I'd like to deauthorize one computer.
    Thanks,
    Jerry

    There is no list.
    You can only deauthorize a single computer from that computer.
    If you do not have access to the computers, then you would have to deauthorize all.

  • How can I determine what is using my broadband?

    I have limited broadband (not uncapped) but something is chewing up my available data at an alarming rate. How can I determine what it is and how to stop it?

    You should be able to click on the one item, and then
    select Info, to see what else is involved w/ this kernel.
    And check the Console utility, to see what (among so
    many) specific items may relate to the use of internet.
    Items by Time & Date narrow the field somewhat.
    Good luck & happy computing!

  • How can we determined what role contains a particular privilege.

    Hi All.
    How can we determined what role contains a particular privilege.???
    I have found note User Management (UMX) Security Infrastructure Reporting (Doc ID 1222663.1)
    Our implementation doesn't seem to have a "UMX_W3H_HOMEPAGE / W3H Homepage Permission Set"
    This is a R12.0.4 instance
    Thanks in advance

    How can we determined what role contains a particular privilege.???User Management Responsibility > Roles & Role Inheritance > Search for the Role > Click on Edit and you will find the list of Permissions.
    I have found note User Management (UMX) Security Infrastructure Reporting (Doc ID 1222663.1)
    Our implementation doesn't seem to have a "UMX_W3H_HOMEPAGE / W3H Homepage Permission Set"
    This is a R12.0.4 instanceAccording to (How to Assign User Management Security Reports to a User [ID 1221304.1]), it is available in 12.1.1 and above.
    Thanks,
    Hussein

  • HT5622 how can I find what the charges aree to my credit card from the apple store? I get multiple charges every month and don't know what they are for...I want to cancel whatever is being charged to me...how do I do it?

    how can I find what the charges aree to my credit card from the apple store? I get multiple charges every month and don't know what they are for...I want to cancel whatever is being charged to me...how do I do it?

    Have a look at this link
    http://support.apple.com/kb/ht2727

Maybe you are looking for

  • Error message into a Variable.

    Dear users, I have a rather usual (unusual from the weekend beers for me though!!) query which I can't figure out a proper way to implement. My requirement is like this: I have a message class in which I want to define a text 'Employee number & not f

  • HP 3050 will not stay on the wireless network for more than a few minutes at a time.

    My HP DeskJet 3050 J610 is constantly dropping the wireless connection. It won't stay on for more than a few minutes. If I power cycle, it comes right back on, but drops again after a few minutes. It will print fine from a USB. When it drops off, pin

  • Error While Burning to Disc

    I've tried to burn two separate DVD files to disc using iDVD 5.0.1. Both times a dialogue box came up saying "Burning Finished. Errors were found during the burning process" The recording device reported the illegal request: Cannot write medium – inc

  • Trying to update iphone from ios4.x to 5.x moved iphoto

    Moved Iphoto and Itunes libraries to external drive with 700 GB+ available (Those applications won't open anything without the drive hooked up-I think those moves are legit.) when I click the button in itunes that says " a newer version of the iphone

  • Can't view geometry

    I have recently started to use java 3d and want to be able to load and view wrl files that have been created in other packages. I am using netBeans and have no trouble compiling and running the simple program I have created. I have searched here and