Why JVM treats every thing as a String only

Hi
If i am passing any input i.e primitive values from command prompt, I want to convert it once again back to primitives by using Integer.parseInt().
Why JVM is treating everything as a String only. why can't it read as primitives itself ?
Any reason behind that ?

It's not the JVM, it's the operating system, in fact all operating systems I've ever worked with (and there've been quite a few).
You type a string on the commandline, the operating system couldn't care less what data is in that string.
It only takes the parts it needs to determine what the actual program to start or command to run is, and passes the entire string to that.
The command or program then can do whatever it wants with that string.
The JVM works in the same way. It parses the string to figure out what its classpath is and what class to launch, and passes everything else on to that class (it is nice enough to turn it into an array for you).
It can't know if when you type a number it's supposed to be a number or not. It can't know whether a letter you typed was actually supposed to have been a number but was a typo, or maybe it is a number in some other numbering system (think hexadecimal).

Similar Messages

  • Why jvm maintains string pool only for string objects why not for other objects?

    why jvm maintains string pool only for string objects why not for other objects? why there is no pool for other objects? what is the specialty of string?

    rp0428 wrote:
    You might be aware of the fact that String is an immutable object, which means string object once created cannot be manipulated or modified. If we are going for such operation then we will be creating a new string out of that operation.
    It's a JVM design-time decision or rather better memory management. In programming it's quite a common case that we will define string with same values multiple times and having a pool to hold these data will be much efficient. Multiple references from program point/ refer to same object/ value.
    Please refer these links
    What is Java String Pool? | JournalDev
    Why String is Immutable in Java ? | Javalobby
    Sorry but you are spreading FALSE information. Also, that first article is WRONG - just as OP was wrong.
    This is NO SUCH THING as a 'string pool' in Java. There is a CONSTANT pool and that pool can include STRING CONSTANTS.
    It has NOTHING to do with immutability - it has to do with CONSTANTS.
    Just because a string is immutable does NOT mean it is a CONSTANT. And just because two strings have the exact same sequence of characters does NOT mean they use values from the constant pool.
    On the other hand class String offers the .intern() method to ensure that there is only one instance of class String for a certain sequence of characters, and the JVM calls it implicitly for literal strings and compile time string concatination results.
    Chapter 3. Lexical Structure
    In that sense the OPs question is valid, although the OP uses wrong wording.
    And the question is: what makes class Strings special so that it offers interning while other basic types don't.
    I don't know the answer.
    But in my opinion this is because of the hybrid nature of strings.
    In Java we have primitive types (int, float, double...) and Object types (Integer, Float, Double).
    The primitive types are consessons to C developers. Without primitive types you could not write simple equiations or comparisons (a = 2+3; if (a==5) ...). [autoboxing has not been there from the beginning...]
    The String class is different, almost something of both. You create String literals as you do with primitives (String a = "aString") and you can concatinate strings with the '+' operator. Nevertheless each string is an object.
    It should be common knowledge that strings should not be compared with '==' but because of the interning functionality this works surprisingly often.
    Since strings are so easy to create and each string is an object the lack ot the interning functionality would cause heavy memory consumption. Just look at your code how often you use the same string literal within your program.
    The memory problem is less important for other object types. Either because you create less equal objects of them or the benefit of pointing to the same object is less (eg. because the memory foot print of the individual objects is almost the same as the memory footpint of the references to it needed anyway).
    These are my personal thoughts.
    Hope this helps.
    bye
    TPD

  • Why every thing resets ?

    I'm wandering why when I restart my imac, every thing resets; like I sate my dock on the left it. I organized my book marks, but when I restarted my imac. every thing become at an original place and all my bookmarks gone. and dock at the bottom on the original place. why it resets each time I restart my iMac ? please help....

    Tigor:
    With all the issues you seem to report, it may be better if you went to an Apple Store and asked for someone to take a look at your OS installation, etc.
    If there are complex issues, this is the best way to sort them out...if there is something about using the OS you need help with, this is also a great way to get face-to-face explanations, demonstrations, etc.
    Good luck in any case.

  • Im having trouble with error 13019 I have read the previous discussions about this matter and have tried to do them except for the fact that under the music tab when clicking on my ipod every thing is frozen. It s not my comp. and i dont wish to restore.

    Im having trouble with error 13019 I have read the previous discussions about this matter and have tried to do them except for the fact that under the music tab when clicking on my ipod every thing is frozen. It s not my comp. and i dont wish to restore. Please help!

    If you are wondering why you are not getting any responses, it is because you have vented a complaint without any details that make any sense or give anyone something to work on.
    If you want help, I suggest actually detailing what has happened, with versions of software etc. Anything that would let us assist.
    As a start I am guessing that you have not really got the hang of "How it all works". Firstly download the Pages09_UserGuide.pdf from under the Help menu. Read that and view the Video Tutorials in the same place. A good addition would be the iWork 09 Missing manual book and something to help you learn how to use your Mac.
    If there are specific tasks you need help with:
    http://www.freeforum101.com/iworktipsntrick/index.php?mforum=iworktipsntrick
    Is a good resource.
    Peter

  • Hay. i change the screen LCD in IPAD 2 3G but i don't know what happen. She was working and every thing it's ok. One time i turn off the ipad and turn on more time, i don't see good in LCD the  brightness is to low and i can see any thing

    Hay. i change the screen LCD in IPAD 2 3G but i don't know what happen. She was working and every thing it's ok. One time i turn off the ipad and turn on more time, i don't see good in LCD the  brightness is to low and i can see any thing!! and i want to know why is happen

    Assuming you mean that you performed the repair yourself, it would seem that you either obtained a defective screen or you did some sort of damage when you replaced the screen. You can try asking for assistance on ifixit.com, a site dedicate to those attempting their own repairs, or you can take the iPad to a shop and pay them to try to correct the problem for you. Apple will no longer touch your iPad now that you've attempted your own repairs.
    Regards.

  • Every thing that is wrong with the PRE's post!

    I tried looking through the forums but my phone is refusing to cooperate so I have to place this thread here. Please feel free to move it to the appropriate forum later.
    •The internet always seems to reload my pages making it impossible to hit the back button for it delets my previous pages. 
    •Sluggish response from every thing. Which leads to a locked phone.
    •To often told "no room for new cards, close cards!"
    •Email has been on the fritz telling me "it cannot connect to (insert)".
    •Since the update(1.4) I can't pinch when using pdf files, so viewing size is compromised significantly.
    These are the host of problems I can come up with in 15minutes. I'm sure I am likely to have problems with my video recording program, but I never used it.

    defbyblues wrote:
    How often does palm admin frequent here? 
    Why not search for his posts yourself?  You would get an accurate answer that way... 
    WyreNut
    I am a Volunteer here, not employed by HP.
    You too can become an HP Expert! Details HERE!
    If my post has helped you, click the Kudos Thumbs up!
    If it solved your issue, Click the "Accept as Solution" button so others can benefit from the question you asked!

  • Incrementing every letter in a string that occupies an odd position.

    Hi, for an "encryption" project, i need your help creating a method that will be incrementing by 5 every char in a string that occupies an odd position in that same string.
    For example : 'adam' should return 'aiar'
    -Method can't use arrays.
    -Method can't use regular expressions like 'split' etc..in order words the teacher wants us to use the simplest stuff inside the String class.
    -Only letters must be modified.
    so far i have this : (names of values are in french, sorry)
    public class Main {
    public static String incrementerDeCinqImpaires (String chaine) {
    char j = chaine.charAt(1);
    char x = chaine.charAt(3);
    char o = chaine.charAt(5);
    j+=5;
    x+=5;
    o+=5;
    System.out.println(x);
    System.out.println(j);
    System.out.println(o);
    String   tmpString = chaine.replace( chaine.charAt(1), j );
    String   tmpString2 = tmpString.replace( tmpString.charAt(3), x );
    String   tmpString3 = tmpString2.replace( tmpString2.charAt(5), o );
    System.out.println( "Original = " + chaine );
    System.out.println( "Result   = " + tmpString3 );
    return tmpString3;
    public static void main (String args [] ) {
           System.out.println (incrementerDeCinqImpaires("adam"));
    }The thing is i need a "for" loop (which has been a nightmare for me trying to figure out how to make it) in order to increment every odd positioned char in the string.
    So all I need really is to sum up what i posted above inside a for loop (or more). Then just add ifs and elses so i can increment only letters.

    I don't think String.replace will do what you want. What happens when a single letter appears in an even-numbered position and then in a later odd-numbered position?
    Can you use StringBuilder?
    Or you can do a bunch of String appends (i.e., use StringBuilder implicitly), one character at a time, in a loop.
    By the way you haven't done the part where you check that the character is a letter.
    Also, what do you do with the last five letters of the alphabet? (Regardless of the alphabet you're using.) You could end up inserting control characters or characters that you can't print in your locale. Do you wrap?

  • Why is it every time I try to buy itunes I am diverted to the Chinese store and cannot pay for my items? Can anyone help?

    Why is it every time I try to buy itunes I am diverted to the Chinese store and cannot pay for my items? Can anyone help? I have tries to select the English store but it will not allow me to proceed. I think it has been hacked in the past as there is a list of Chinese Apps which it seems to be awaiting payment for, going back to 2011.

    Free Disk Space & Memory are 2 differen't things.
    At the Apple Icon at top left>About this Mac, click on the text below Mac OS X where it says Version 10.4.x and report the Build# please.
    Then click on More Info>Hardware and report this upto but not including the Serial#...
    Hardware Overview:
      Model Name:    iMac
      Model Identifier:    iMac7,1
      Processor Name:    Intel Core 2 Duo
      Processor Speed:    2.4 GHz
      Number Of Processors:    1
      Total Number Of Cores:    2
      L2 Cache:    4 MB
      Memory:    4 GB
      Bus Speed:    800 MHz
      Boot ROM Version:    IM71.007A.B03
      SMC Version (system):    1.21f4
    Then we cn tell you huw to add more RAM & which is the correct RAM Memory.

  • Having just bought an iMac and set every thing up I have found that my IPad seems to run very slow. I have also just updated the IPad to OS 5.1 .Are these two things connected or is there a problem with the IPad

    Having just bought an iMac and set every thing up I have found that my IPad seems to run very slow. I have also just updated the IPad to OS 5.1 .Are these two things connected or is there a problem with the IPad

    Using the Mac with your iPad has nothing to do with the fact that the iPad is running slow. There could be any number of reasons why the iPad is now running slow.
    Have you tried a reset on the iPad?
    Reset the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider - let go of the buttons.

  • Every thing is object?(thinking in java)

    every thing is object.(thinking in java)
    then int and float?
    Does java is a complete OO language

    Hi!
    it is nice question..
    int, float, double, char, ...all are data types as they are in C++.But in Java one can also find wrapper classes(Objects) for these all data types like Integer, Float, Double, etc..so by this one can treat "java as Fully Object Oriented Programming...isn't it.??

  • My ipod will not sync after i got my computer back it wnats me to erase every thing how do i sync and still have all my apps and things like that

    ive tried to sync my ipod touch 3gen but every time ive tryed it say i have to erase every thing to get my new songs how do i sync it with out having to do that

    You can re download past purchases after you restore the iPod.
    Downloading past purchases from the App Store, iBookstore, and iTunes Store

  • I can't get some song on my iphone they work off of the computer but they wont show up on my phone they are in the "on my iphone" section but they gray and have a gray dotted circle next to them i have tried every thing I just want them on my phone HELP!

    I can't get some song on my iphone they work off of the computer but they wont show up on my phone they are in the "on my iphone" section but they gray and have a gray dotted circle next to them i have tried every thing I just want them on my phone HELP!!!

    You have posted to the iTunes Match forum, which your question does not seem to be related to. Is your question concerning iTunes Match or syncing with iTunes via USB?

  • Hey iphone an iphone 3g and i only have about 13 apps and the yellow bar on itunes for my phone is way to big i deleted all my photos all my music every thing i ryed restoring ans all it still takes up space for sum reason ?? please someone help me

    hey iphone an iphone 3g and i only have about 13 apps and the yellow bar on itunes for my phone is way to big i deleted all my photos all my music every thing i ryed restoring ans all it still takes up space for sum reason ?? please someone help me

    If Other (the yellow bar) is too big something is corrupted.  The only solution (that I know of) is to restore from your most recent backup using iTunes (see http://support.apple.com/kb/ht1766).

  • My Macbook was hacked by somebody right after activating downloaded VLC player. I couldn't control my machine. Every thing was messed up! Finally after reboot I realized that even my administration password was changed. Stupid hint I was able to reed: Wha

    My Macbook was hacked by somebody right after activating downloaded VLC player.
    I couldn’t control my machine. Every thing was messed up! Finally after reboot I realized that even my administration password was changed. Stupid hint I was able to reed: What located in box above low case ? I used my friends computer and founded hot to fix my problem using Unix commands to reboot in a single user mode. I founded a lot of different solutions which had prity the same beginnings but very complicated continuation, which, I understood will force me to cach during restoration anuther crap – time bomb in my mac! Finaly I did restor. somehow. But still feel somebodyies presents. Safary messed up – I will send you a log Itunes – messed up. Speaker in a top menu – grayed, and I can’t control my volume. But the most triky thing – bouth my Apple keybords – internal and mostly bluetouth external also working and typing wired! I am sorry for my spelling, because I cant check spell for Mac’s Word (in Microsoft it was F7) I have also several attacks from my neighbors by community I know their names, because they are somethere very close to me – I can see them throuth FI-FI connection. They often kick-me out from my place and started to use my resaurces. And also Mackeeper make me a hard time!
    In Microsoft times u just reinstalled computer – clean installetion from corporate licensed disk. But now I am a beginner in MAC – I love it! But a lot of new and triky – at this way
    Fore example – my goal – to do fool Macbook backup at external USB drive using boot srartup option and make my life yaser in case of crash. But now, I don’t know if I can trust recommended program  Carbon copy cloner – Ms. Bombich?
    I am very sorry for my spelling, because I feel somebodies presents, who playin with me.
    Final question Do I need some antivirus Mac compatable which is update paches, service packs? How to map defolt documents folder not to a local, but to external USB?
    Esquse me for a lot of questions, but I am beginner in MAC, and I LOVE it!
    PS. Good news. Looks like Safari came back! Somebody, probably allredy helping!
    But my interface qute different from original – so something still wrong!

    Didn't really read much at all of your post. Much, much too long, irrelevant details and & no paragraphs.
    Can't use time machine due to corruptness
    Post over here -> Mac OS X v10.6 - Snow Leopard forum
    About my macbook and apple ID how can I upgrade my Macbook from 10.6.3 to 10.6.8 with out all the permissions being changed and corrupt??
    Same as above. Post in the correct forum.
    Need to gain access to my apple Id that would be a great start
    -> http://support.apple.com/kb/HT5625

  • HT204161 I want to use iCloud for every thing else except for Messages. I do not want to send an iMessage and receive it on both my iPhone and Mac.

    I want to use iCloud for every thing else except for Messages. I do not want to send an iMessage and receive it on both my iPhone and Mac.
    How do I do that?

    Howdy kingtonz,
    If I understand you correctly, you want to limit to limit your use of the Messages application to non-iCloud sources such as text messaging through your phone carrier, is that right?
    You can turn off the use of iMessages in Settings > Messages > iMessage. See this help article -
    Messages settings - iPhone
    Thanks for using Apple Support Communities.
    Best,
    Brett L 

Maybe you are looking for

  • HT2534 How to remove credit card information from AppleID

    Hi guys, I bought one Apps from itunes store using credit card. Now, I want to remove my credit card information from this. However, there is no such button or icon as "Remove Credit Card info"/ Credit Card "None". I'm do not think if the Credit Card

  • Model View Empty

    OTN, We installed AWM 10.2.0.3A in Wnidows XP from the available download link, and did Administrative installation as advised in a solution we found in past blog. However, we're still not able to see AW created when we switch from Object View to Mod

  • Billing Based on DIP Profile - PS - SD Line Items Structure

    Hi, I have created a sales order with 1 line item which is linked with a WBS Element via account assignment. Based on the line item and WBS structure & Activities. I am billing the customer by creating a debit memo from DP91. The billing is POC basis

  • Check see if string passed in param matches with substring in the data str

         // method that check to see if the string passed as the param appears as a      // substring in the data string      public boolean lookSubstring(String _data)           for(int i = 0; i < _data.length(); i++)                if(_data.equals(data

  • Problem : writing values to table continously

    i am using for loop to write values to table. N=10 is set for the loop. now table is showing values after 10 iterations of the loop but i want to take value of each itration. actually i am measuring resistivity at different temperature using agilent