What does the trim() method of the String class do in special cases?

Looking here ( String (Java Platform SE 7 ) ), I understand that the trim() method of the String class "returns a copy of the string, with leading and trailing whitespace omitted", but I don't understand what the last special case involving Unicode characters is exactly.
Looking here ( List of Unicode characters - Wikipedia, the free encyclopedia ), I see that U+0020 is a space character, and I also see the characters that follow the space character (such as the exclamation mark character).
So, I decided to write a small code sample to try and replicate the behaviour that I quoted (from the API documentation of the trim method) in the multi-line comment of this same code sample. Here is the code sample.:
public class TrimTester {
    public static void main(String[] args) {
         * "Otherwise, let k be the index of the first character in the string whose code
         * is greater than '\u0020', and let m be the index of the last character in the
         * string whose code is greater than '\u0020'. A new String object is created,
         * representing the substring of this string that begins with the character at
         * index k and ends with the character at index m-that is, the result of
         * this.substring(k, m+1)."
        String str = "aa!Hello$bb";
        System.out.println(str.trim());
However, what is printed is "aa!Hello$bb" (without the quotes) instead of "!Hello$" (without the quotes).
Any input to help me better understand what is going on would be greatly appreciated!

That's not what I was thinking; I was thinking about the special case where the are characters in the String whose Unicode codes are greater than \u0020.
In other words, I was trying to trigger what the following quote talks about.:
Otherwise, let k be the index of the first character in the string whose code is greater than '\u0020', and let m be the index of the last character in the string whose code is greater than '\u0020'. A new String object is created, representing the substring of this string that begins with the character at index k and ends with the character at index m-that is, the result of this.substring(k, m+1).
Basically, shouldn't the String returned be the String that is returned by the String class' substring(3,9+1) method (because the '!' and '$' characters have a Unicode code greater than \u0020)?
It seems to not be the case, but why?

Similar Messages

  • How does the String class achieve this.

    How come we can do the following with the String class:
    // The class is initialized using the equals sign!
    String s = "Hello, World"";I am currently checking the string class but can not find what makes the above possible. could anyone help me?

    ok sorry for not being so clear :)
    When having a String class, we can initialize it by doing the following:
    String myString = "Hello World"; Whis as JosAH explained it is handeled by the compiler. However my common sense tells me that the String class is nothing but a normal class (not like int, long, etc). So if it a normal class, then in that class there is a way to understand what = "somthing" means, and update it's state accordingly.
    I would like to do the same think with my class. example:
    Person MyPerson = "John, Smith";The above is a stupid example, however it gathers my point. The String class sess what is inside the quates and updates it state (with the help of the compiler). Can the Person class do the same? how?

  • What does the SomeClassIdentifier.class keyword do?

    I see this often.
    SomeClassIdentifier.class == SomeClassIdentifier.getClass() ?

    I see this often.
    SomeClassIdentifier.class == SomeClassIdentifier.getClass() ?Not quite; the getClass() method is a non-static method inherited from the Object class.
    It returns a Class object representing the runtime class of the object for which the method was
    invoked. The funny .class notation is a class literal, it also evaluates to a Class object, but
    this object will represent the type that was mentioned on the left of the dot. e.g. -- Object a= new String("foo");
    String  b= new String("bar"); both a.getClass() and b.getClass() will return a Class object for the String class.
    String.class will evaluate to that same object, but Object.class wouldn't of course ...
    You can even create class literals for primitive types or arrays of even for void.
    kind regars,
    Jos

  • CSCC - what does the "id" mean and how to get it

    https://apps.cisco.com/CustAdv/ServiceSales/contract/productDetailsIndex.do?method=loadProductDetails&contractId=55565082772&serviceLineNumber=55565082912&lineID=55565086982&instanceID=1483016052&contractNumber=93913779&id=382878711&majorOrMinor=MAJOR&coveredOrUncovered=COVERED&lineSeqNo=45823525&contextID=0.4317186686218467
    Currently I am developing a web client tool to get contract information based on the SN. And I don't find any existing API of CSCC, I had to parse the html instead. But I encountered an issue here as $subject which highlighted in the above link. What does the id number mean and how can I get it ?

    Are you running Firefox in Windows 95 or 98 compatibility mode?
    Mozilla/5.0 ('''Windows NT 4.0'''; rv:35.0) Gecko/20100101 Firefox/35.0
    Firefox won't install on Windows NT 4.0 - so something is changing your useragent and saying that your operating system is like 20 years old.
    Right-click your Firefox desk-top shortcut and select Properties. Then open the Compatibility tab and look at '''Compatibility mode''' - un-check that box if it has a check-mark.

  • What does the standard program  RFBIBL00    does?

    what does the standard program  RFBIBL00    does?

    Hi Bharath
    Accounting Documents: Data Transfer Workbench
    Definition
    Transferring FI accounting documents from an external system into the SAP System using program RFBIBL00.
    Use
    You use program RFBIBL00 to enter accounting documents and to clear open items.
    Method
    Program RFBIBL00 primarily transfers accounting documents using the batch input method. However, you can also generate documents immediately using call transaction or direct input by means of the "Data transfer type" parameter. Both of these procedures lead to improvements in system performance when transferring large quantities of data (more than 10,000 transactions).
    Object-Specific Settings
    With call transaction or direct input, documents are posted immediately to the SAP System. As a result, you need to ensure that if for any reason the program is terminated, it can be restarted without inconsistencies occurring in the data.
    other information:
    To enhance the batch input procedure, the system offers the direct input technique, especially for transferring large amounts of data. In contrast to batch input, this technique does not create sessions, but stores the data directly. It does not process screens. To enter the data into the corresponding database tables directly, the system calls a number of function modules that execute any necessary checks. In case of errors, the direct input technique provides a restart mechanism. However, to be able to activate the restart mechanism, direct input programs must be executed in the background only. To maintain and start these programs, use program RBMVSHOW or Transaction BMV0.
    Examples for direct input programs are:
      Program        Application
    RFBIBL00         FI
    RMDATIND       MM
    RVAFSS00       SD
    RAALTD11        AM
    RKEVEXT0       CO-PA
    Hope this helps u
    thanks and regards
    suma sailaja pvn

  • What does the community recommend as an appropriate response in light of reports that "an estimated 600,000 or more Macs are currently compromised and part of a massive botnet thanks to the Flashback Trojan."  Is Apple taking steps to mitigate the threat?

    What does the community recommend as an appropriate response in light of reports that "an estimated 600,000 or more Macs are currently compromised and part of a massive botnet thanks to the Flashback Trojan."  Is Apple taking steps to mitigate the threat?
    See article in PC World at:  http://www.pcworld.com/businesscenter/article/253403/mac_malware_outbreak_is_big ger_than_conficker.html
    I have a MacBookPro and my wife has an iMac. I assume both are equally vulnearble.
    MLSCOS

    There are checks one can perform to see
    1: If any of their machines have been seen on the Flashback botnet
    http://public.dev.drweb.com/april/
    2: Terminal commands to see if their machine is infected (use copy and paste, then press enter)
    https://www.f-secure.com/v-descs/trojan-downloader_osx_flashback_i.shtml
    3: Preventative methods to avoid becoming infected.
    Update Java via Software Update.
    Disable Java in all your web browsers preferences (notice Java is not Javascript)
    Check your status of all browser plug-ins
    https://www.mozilla.org/en-US/plugincheck/
    Firefox + NoScript add-on + Temp Allow All Button on Firefox's toolbar to turn on scripts only on sites you trust.
    Learn how to make bootable clones, this way a complete erase can occur and a reverse clone done.
    https://discussions.apple.com/community/notebooks/macbook_pro?view=documents
    4: Resources if one is infected
    Data Recovery, wiping entire machine, reinstalling OS X, returning clean files, etc.
    https://discussions.apple.com/community/notebooks/macbook_pro?view=documents

  • What does the checkmark do, in iTunes?

    I've been wondering for a quite a while now, what does the checkmark do next to the Track Title?

    The check can be used for various things:
    1. When playing in random mode, unchecked songs do not play
    2. For the ipod, you have an option "sync only checked songs"
    3. Can be used in smart folders in the "Match only checked songs" option
    4. If you don't want to import tracks on a CD you can uncheck them and click import
    I think there may be a couple of other things it can do too.
    Tip: If you want to check/uncheck a whole album, select the album in browser and command-click any track - voila the entire album is unchecked/checked (note: you can select multiple albums by command or shift-clicking them in the browser window and use the same method, OR do it to entire genres or artists the same way - whatever is shown in the tracks part of the window will be checked/unchecked)

  • What does the word Factory mean in "naming factory "

    What does the word Factory mean in "naming factory" in JNDI tech?

    A Factory class is a class that produces an instance of an object. For example, a ParserFactory class will have a method that returns a Parser. Usually this Factory class is looking at something in the environment to decide which object to return. "Factory" is just one of many "Design Patterns" that you will encounter in the programming world. Several (many?) books have been written about design patterns.

  • What does the class CL_EXITHANDLER do ? What the significance of this class

    what does the class CL_EXITHANDLER do ? What the significance of this class,

    Peters,
    Welcome to SDN!
    you can see this class in SE24 and than choose GET INSTENCE method DB on it. than put break-point on
    CALL METHODcl_exithandler=>get_class_name_by_interface
    finally run any t-code you will come into debugger mode and if you see in exit_name value after pressing F6 you will get BADi name of this perticuler T-code.
    basically we use this class for findings BADi.
    Amit.

  • What does the word "static" really mean?

    Yep, that's the question. What does the word "static" really mean?
    /Martin

    hi static means that u can use it with out creating an object of this class
    i.e. Class.Staticmethod()
    e.g. Math.pow(7,2)
    non static means u hava to create an object to use it
    like ClassObject.method()
    and remember it doesn't fit only for methods it fits for all members of a class i.e. methods and variables

  • What Does The Log Message "Rejecting update: Lease..." Mean?

    I use RelicatedCache and TransactionMap on Coherence 3.4.2.
    I saw "Rejecting update: Lease..." message.
    What does the log message mean?
    2011/10/18 06:41:57.506 [DEBUG] Logger@9263394 3.4.2/411p16 N/A NOAH Coherence 3.4.2/411p16 [D4] (thread=ReplicatedCache, member=2): Rejecting update: Lease: [-8863526970089418959, -2793231267399579492, R] (Cache=issue-code, Size=Unknown, Version=0/0, IssuerId=1, HolderId=0, Status=LEASE_AVAILABLE, Last locked at Thu Jan 01 09:00:00 JST 1970)
    by member=2, Lease: [-8863526970089418959, -2793231267399579492, R] (Cache=issue-code, Size=143, Version=0/0, IssuerId=2, HolderId=0, Status=LEASE_AVAILABLE, Last locked at Tue Oct 18 06:41:51 JST 2011)
    I found a Note 1065352.1, but the message is little differnt...
    Note 1065352.1
    "What Does The Log Message "Rejected update: Lease..." Mean?"I'd like to know following 2 points..
    - What does "Rejecting update: Lease..." message mean?
    Do thsese messages have same meaning?
    - My application didn't catch any exceptions, and
    "CacheFactory.commitTransactionCollection" returned true.
    So this "Rejecting update: Lease..." is not a error message, right?
    (Does the transaction commited successfully?)
    Thanks in advance.
    -Noriyuki

    Hi
    These are decoded results of the error message which u have recd in ur box..
    %C4K_PKTPROCESSING-4-ERRORPACKET: [char]
    The software is unable to process a packet; the packets have been forwarded to the CPU instead and the packet will be dropped.
    Recommended Action: This is an informational message only. No action is required.
    %C4K_HWACLMAN-4-WARNINGSTRING: [char]
    A nonspecific warning message was displayed.
    Recommended Action: See the message string [char] for more information.
    Related documents- No specific documents apply to this error message
    %C4K_HWACLMAN-4-WARNINGSTRING: [char]
    A nonspecific warning message was displayed.
    Recommended Action: See the message string [char] for more information.
    Related documents- No specific documents apply to this error message.
    regds

  • I was playing with my ipad settings (it's an older model) and noted in the advanced settings of Safari there was a place to view website databases.  When I clicked on this I saw websites.  How do these get there and what does the space amount mean?

    I was playing with my ipad settings and noted in he advanced settings of Safari there was a place to view "website databases".  When I selected this I saw a multitude of websites.
    Can anyone tell me how these get there?  Can a website be posted even if it was never went to?  What does the space amount mean?  For example, 1.5 kb...is this quite a bit?  Would it indicate someone has gone to a site multiple times?
    I share my ipad with my teenage daughter and I'm trying to find out if she's lying to me.  Obviously she's swearing that she has "no idea" how these got there and I'm trying to keep her safe (she's only 14).
    Thanks everyone.
    Concerned Mom

    Think of your PC and the 'temporary internet folder' where it keeps cached copies of web pages or elements off a web page for 'quicker display the next time you visit'. That's pretty much what that folder is. 1.5K is tiny. Probably just a basic page with some text on it. (you might be confusing 1.5K with 1.5 megabyte....megabyte is large...it's roughly 1000 kilobytes, so the 1.5K is a tiny file)
    As far as I know, the only way info gets into that folder is if the browser has been to that site.
    if you have a concern there are browsers out there, McGruff is one i've seen recommended, that allow some degree of parental control and supervision. That or you could passcode lock the iPad or enable the restrictions to turn off some parts of the device to have some control.

  • What does the open file dialog do 'under the hood' and is there a way to simulate it

    What does the open file dialog do 'under the hood' and is there a way to simulate it?
    I have a bug in my code (that I've posted about before, here) which I can't fix at the moment, but I do have a workaround.
    Briefly, the bug:
    I call a dll from a function node, to initialise and run a spectrometer. If I start up the PC, LabVIEW and run my vi the code runs without complaint, the first call to the dll to initialise the spectrometer doesn;t return an error but the spectrometer is not detected either.
    I've tried various solutions, see the link above, and none work
    The workaround:
    If, at any time before running the code containing the function node I open an 'open file' dialog window, select the dll and click ok/hit enter then everything is fine. When I run the main code the spectrometer is detected.
    I use an express vi to open the file dialog, I specify the start path and file name as constant inputs and just click ok/hit return when the dialog pops up. I don't do anything with the dialog outputs. In fact the vi that contains the open file dialog can be run before the project containing the bug is even open.
    I have to do this everytime I turn the PC on.
    So, either
    1) Can somewone suggest a fix for the original bug?
    2) What is the easiest way to simulate the enter keypress when the open file dialog pops up
    or
    3) Can someone tell me what the open file dialog does under the hood that somehow causes the dll to work and can it be simulated in straight LabVIEW
    I suspect that the dll itself is dodgy ( I have in the past talked to the supplier but not got very far, and I will try again but I would like a quick, temporary solution too). I'm guessing that the file dialog is making some kind of check on the file, and possibly registering its presence with the OS (winXP). I tried using the file/folder exists vi to see if checking the file like that worked but no luck.
    Any help greatly appreciated.
    Dave

    Hi David
    I am very conscious about thread hijacking but this sounded like my issue so I hope you dont mind me asking about your issue. I am hoping that you have a spectrometer from the same vendor as me and its not just me seeing an Error 1097 issue. My spectrometer is from a company called Stellarnet.
    So far I have unable to get it to work with other VIs. There is one condition where I can get it to work but its no good for me.
    Case 1
    I open the VI in a fresh labview environment with no other VIs in memory. The code runs with no issue.
    Case 2
    Labview is not opened. I double click the spectrometer VI in windows explorer.  The VI opens but it fails to run resulting in Error 1097. Personally, I dont see the difference between this and Case 1 above and yet it fails.
    Case 3
    If I already have other VI's in memory and try to load the spectrometer VI and run it fails with Error 1097. This case is the one that most important to me. I have a test executive that will load test VIs dynamically and I can't get this to work. Same problem Error 1097.
    I wanted to share what I have seen with you and to let you know that maybe somebody else has the same issue. I am convinced its the DLL but the vendor dis-agreed saying it was LabVIEW. I couldn't convince him otherwise.
    Thanks in advance
    David

  • What does the ipod touch 5 come with

    What does the Ipod Touch 5 come with? (standard)

    Four calling birds, three french hens, two turtle doves and partridge in a pear tree. ;-)
    Basic troubleshooting steps  
    17" 2.2GHz i7 Quad-Core MacBook Pro  8G RAM  750G HD + OCZ Vertex 3 SSD Boot HD 
    Got problems with your Apple iDevice-like iPhone, iPad or iPod touch? Try Troubleshooting 101
     In Memory of Steve Jobs 

  • What does the recovery CD contain - Satellite A100-847

    Hello guys
    I had a few questions about the recovery CD:
    1- What does the recovery CD contain? and the other CD which is called Media something?
    2- Does it have Windows in it? So I can format my PC using it? And from where can i find the product key (windows key)
    3- What if i wanted to use the CD without formatting? etc. installing the softwares?
    Sorry for asking too much but my laptop started disturbing me. Just for knowledge my Laptop is satellite A100-847

    Hello
    I will try to answer your question.
    1 Recovery media contains recovery image. Recovery image is a kind of package that contains operating system, all necessary drivers, Toshiba tools and utilities and some additional software like WinDVD or Norton antivir application. Media something is not known to me. Maybe exact description can help.
    2 Yes it has Windows OS. Yes you can format your notebook using it. You do not need product key. Just install it.
    3 I do not know what you mean. The fact is that HDD will be formatted before you start recovery installation. Be sure all your important data are saved on some external device.
    Bye

Maybe you are looking for

  • Need help on subform of adobe

    hai everybody,                      I am using subform ui element for creating a table in interactive form.I am able to correctly get the data in rows that i have binded dynamically using datasource property. My problem is in my application i am havi

  • My iPad photo app is "locked".

    I have been using apple products for years and I am somewhat of an expert. I have never had any problems such as this. When I was using my iPad I decided to look at pictures. I clicked the "Photos" app and all of a sudden it has a countdown for half

  • ALV Report to check upto current fiscal year

    Hi All, I am running a reoprt. its output is in this way. Division                Fiscal year                                  Net Price. Chemical              2006                                              3456456                             2007

  • I can't do anything about error 150:30

    I've tried everything I've seen online about fixing error 150:30 that my licensing has stopped working but nothing seems to work

  • On which of the database

    Hi Team, One my team member has provide some permissions to user on few database of an instance. I need to find which are the permissions have been provided on all the databases of an instance. I need the customized script to find this and also that