Cast string to char

Hello;
Could anyone tell me how to cast a string to char?
for example;
String [] args = {"test", "hello","a"};
how can I cast the args[2] to char = 'a';
Thanks

Hello;
Could anyone tell me how to cast a string to char?
for example;
String [] args = {"test", "hello","a"};
how can I cast the args[2] to char = 'a';
Thanks
If you want to cast a String to a char you cannot. There are some conditions for casting. You just cannot cast anything primitive or object type to anything. how ever if you want to convert a String to a char array you could d othat as follows
refer to String API
public char[] toCharArray()
Converts this string to a new character array.

Similar Messages

  • How to find as ascii value for a string or char in unicode system?

    Hello,
    How to find an ascii value for a string or char in unicode system?
    Thanks in Advance

    hi ,
    report demtest.
    data : c.
    field-symbols : <n> type x.
    data : rn type i.
    c = 'A'.
    assign c to <n> casting.
    move <n> to rn.
    write rn.
    This will convert 'A' to 65.
    Tom Demuyt
    How to convert ascii value to character.
    If I give input as 65 (ascill value) I want display 'A'.
    Below logic is for convert from character to ascii value , now I want to know how to convert ascii value to character.
    Naveen
    report demtest.
    *going from A to 65
    data : c value 'A'.
    field-symbols : <n> type x.
    data : rn type i.
    assign c to <n> casting.
    move <n> to rn.
    write rn.
    *going from 66 to B
    data : i type i value 66.
    data : x type x.
    field-symbols : <fc> type c.
    move i to x.
    assign x to <fc> casting type c.
    move <fc> to c.
    write c.
    regards,
    venkat.

  • String to Char?

    Hi, sorry, I'm new to Java so this may sound like a silly question. I have found how to convert from a String to an Int (with Integer.parseInt() ) - can anyone tell me what the easy equivalent is for String to Char (I want to assign the value of a String to a Char variable).
    Many thanks.
    Traci

    Try string.charAt(0). Don't forget to check that the string should contain at least one char for that to work.

  • String to char conversion

    How do I convert a string I have (I am sure its one character) in to char?

    you must mean char foo, instaead of String!
    char foo = "bar".toCharArray()[0];

  • Write string (7 chars), int16, sgl into binary file and read it in C

    How to write write string (7 chars), int16, sgl, string (5 chars) into binary file and then read it in C ?
    Total 18 Bytes file (binary) should be created.

    Hi,
    this could be done that way:
    You have to make sure the strings have their correct length!
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Field Symbols - STRING to CHAR

    Hi Friends,
    I have a STRING data type declared and Iam trying to pass this data to system function 'C_RSTS_WRITE' for some requirement as below. But it gives me SY-SUBRC as 16. But it works for CHAR datatype which I dont want to use as I have some other reason.
    CALL 'C_RSTS_WRITE'
    ID 'HANDLE' FIELD hlp_handle
    ID 'BUFF' FIELD buffer
    ID 'RC' FIELD _rc
    ID 'ERRMSG' FIELD errmsg. "#EC CICCALL
    My Question is:
    Can we achieve this using Field-Symbols using CASTING.
    In other way can I declare the Field Symbol as CHAR datatype (with no fixed length) which I use in system function and I will pass the STRING data to that field-symbol.
    Please confirm.
    Thanks,
    Smitha.

    Hi Smitha,
    Can u share, how u solved the problem. I have to do the same thing.
    If possible, please email me the code -  silbizkit at gmail.com
    Thanks

  • Urgent: Casting int to char!!!

    I want to convert integer variable that take values between 0 -10 to a char type because i am using the values to call setCharAt() method on a string buffer. But the char casting is not returning the right values. How do i achieve this?

    I think you are better of by using a String because the 10 has two digits.
    Make sure you import java.lang.Integer and do the following
    int i;
    String s = Integer.toString(i);
    Of course you can easily get the char by using the charAt(int index) method of the class String.

  • Problems  with  string larger char(255)

    Hi guys ,
    Something really weird happened to me , i have the following code  to create a  flat file , suddenly it is truncating the lines in 250 ,  its funny i see  wa_ti_fich+330(5)   in the debugging and it has data , but the whole wa_ti_fich is only 255 long , ive tried with type char600 , with the same result , i cant use type string beacuse is not allow for unix file .
    data: begin of ti_fich occurs 0,
            linha(527),
          end of ti_fich .
    wa_ti_fich-linha+49(15)  = montante.
        wa_ti_fich-linha+64(2)   = '02'.   "codigo moeda 02
        wa_ti_fich-linha+106(2)  = '01'. "Codigo de la situación.
        wa_ti_fich-linha+112(8)  =  itab_saida-datav.
        wa_ti_fich-linha+120(8)  =  itab_saida-datav.
        wa_ti_fich-linha+128(8)  =  montante.
        wa_ti_fich-linha+143(2)  = '02'.
        wa_ti_fich-linha+185(2)  = '01'.  "  Naturaleza titular
        wa_ti_fich-linha+187(10) = itab_saida-stceg+2(10).
        wa_ti_fich-linha+197(1)  = '2'.    " Formato do nombre
        wa_ti_fich-linha+198(110) = itab_saida-name1.
        wa_ti_fich-linha+329(1) =  '2'.
        wa_ti_fich-linha+330(110) = itab_saida-stras.
        wa_ti_fich-linha+446(50) = itab_saida-ort01." nom_mun :
        wa_ti_fich-linha+496(2) =  itab_saida-regio.
        wa_ti_fich-linha+501(5) = itab_saida-pstlz.
    append wa_ti_fich to ti_fich .
    please don send me links for scn  or google with similar subjects because i ve already checked it , believe me .
    thank

    255 is the maximum output lengh for CHAR variables in the Old Debugger. So it is normal that you don't see the end of the string in the Old Debugger.
    If you have a newer R/3-Release you can use the New Debugger and choose the output format "Tabular". In this display format, the contents are portioned into 50 characters each and thus you'll see the complete string. In older R/3-Releases, where the New Debugger is not yet available, you will have to input manually offsets in the debugger to see the complete string.

  • How does LabVIEW convert string to char* when passing them to a Call Library Node?

    I have a program which calls C++-based libraries which themself use external libraries (Qt). I pass strings to my library through the Call Library Node, and was wondering how the formatting goes? I have to interpret the char* according to Latin1, UTF-8, UTF-16, ... to convert them to a string which the Qt libraries understand. I need to use char* instead of LV strings, because the library is indepent of LabVIEW.
    It seems that interpreting the char* as Latin1 (default) does not work on Korean systems (for one of our customers), which is understandable when you know that the Latin character set does not know Korean signs. Anyone knows how the char* should be interpreted then? In other words, for non-Latin languages, what exactly is passed to the DLL?

    I don't think that we reinterpret your string in anyway, just reformat the data so that it can be passed to your dll. 
    So assuming you are getting text from, say, keyboard editing, the text should be in the ANSI codepage that the system is running under.  That is, if you are running Windows using an English locale, it will be codepage 1252 (Windows Western, Latin 1), if you are running Windows with a Korean codepage iirc it will be codepage 949, Unified Hangul code.
    If you are filling the string with data that you get from an instrument or some other fashion, it could really be anything.
    Here is a list of the codepages that Windows knows about
    http://msdn2.microsoft.com/en-us/library/ms776446(VS.85).aspx
    I do have some experience with Qt as well, and I think that the function you are looking for to create, say, a QString from this is:
    QString::fromLocal8Bit
    but I am not 100% certain about this as I am not a Qt expert.
    Jeff Peters
    LabVIEW R & D
    Message Edited by jpeters on 04-02-2008 12:38 PM

  • Error when try a "cast" in a char(13) to get a varchar....

    AVAB_Codigo it's a "char(13)", get me a error :
    "Invalid operator for data type. Operator equals boolean AND, type equals varchar."
    when i use a cast...  the error still appear,.....  what should i do ?
    -- 1st attemp --------------------------------------------------------------------
      case when (SUBSTRING(AVAB_Codigo,5,1)='0') 
       then Right(AVAB_Codigo,6) 
       else (SUBSTRING(AVAB_Codigo,5,1) & Right(AVAB_Codigo,6)) 
      end as [UL/UE]
    -- 2nd attempt ----------------------------------------------------------------------
      case when (SUBSTRING(cast(AVAB_Codigo as varchar(10)),5,1)='0') 
       then Right(cast(AVAB_Codigo as varchar(10)),6) 
       else (SUBSTRING(cast(AVAB_Codigo as varchar(10)),5,1) & Right(cast(AVAB_Codigo as varchar(10)),6)) 
      end as [UL/UE],

    The concatenation operation is the plus sign, not the ampersand. 

  • Cast string to single precision

    Hi,
    I try to write a communication between a PC and a DSP which is
    programmed to
    understand some kind of ModBus. I tried to use MBmaster.vi, a freeware
    of AIRtech in the netherlands.
    I was successfull to 90% after a very short time - I get back a string
    from the DSP which makes sense.
    The only problem is to *convert* the 4Byte=8Hex=32Bits(=IEEE754 single
    precision format) into the LabView single precision number it does
    represent .
    In other programming languages like C I think I could do this easily
    on a very low level procedure or with one of these dangerous casts.
    As a newbie to LabView I could not found neither one VI to do this or
    find out which simple combination of VIs could solve the problems.
    Are there any cracks
    here who know *the* easy solution??
    Thanx & Regards
    Urs Bögli

    "Doug (CapeFl)" wrote in message news:<[email protected]>...
    > Did you check the VI functions under Functions>String>Additional
    > String to Number Functions?
    > There are quite a few for converting to/from Hex, etc. I've used them
    > for concatenating 4-bit strings into an 8-bit string (to get an 8-bit
    > byte/word), also converting to/from Hex using some of the VIs I
    > mentioned.
    > Good Luck, Doug
    Dough,
    as a programmer for twenty years I have some problems to understand the way
    labview does work with types and casts - other languages are much clearer about it
    - or have I not found the ultimative help area yet ???
    May I ask you to send me the VI off list?
    thanks
    Urs

  • How to change one character string to char

    hi all
    i got string but only one character
    i got 1,2,3,E
    since i got 'E' here..........
    i need to convert to it to character....
    but how to change it.... i only know String to integer using Integer.parseInt() method....
    but i don't know about char...................

    You should really check the API first:
    http://java.sun.com/j2se/1.4.2/docs/api/index.html
    Take a look at String.charAt(int index) method.
    /Kaj

  • Casting Number as Char - how to hide decimal places?

    I am casting a number as a Char because I am concatenating it with other things. The problem is that when I cast to char, it displays two decimal places of just 0's. I really don't want to show the decimal place or anything after it. Is there a way to remove them?
    Thanks

    Hi,
    You can have two approaches for the same.
    1> cast( cast(column as int) as char)
    2> Go to the column properties(i.e the finger mark on the coulmn heading). Then select the data format tab and check the override the default data format tab. Then you can set the decimal places.

  • Connection String Special char

    Hello,
    I have a problem with databasenames with special characters in the name:
    (My code works when there is not a special char in the name)
    For example, when my connectionstring would be:  jdbc:sybase:Tds:localhost:2638?ServiceName=BANDENM&W
    I get a java.sql.SQLException: JZ00L: Login failed.  Examine the SQLWarnings chained to this exception for the reason(s). at line 3 while my pasw and login are correct.
    Class.forName("com.sybase.jdbc3.jdbc.SybDriver");
      String connectionString = "jdbc:sybase:Tds:" + config.getHost() + ":" + config.getPort() + "?ServiceName=" + databaseName;
      Connection connection2  = DriverManager.getConnection(connectionString, config.getUser(), config.getPassword());
      //get VC client customer info
      statement = connection2.createStatement();
      resultSet2 = statement.executeQuery("SELECT CNR_SUPP,CNR_CUST,TNR_ID,NM_ID,CNR_VAT_ID,NM_FILTER_ID,CNR_ZIP_ID,CNR_VATCNTRY_ID,NM_TOWN_ID,TOP_COUNTRY.CNR_INTRASTAT FROM TOP_IDENTITY JOIN TOP_COUNTRY ON (TOP_IDENTITY.COD_CNTRY_ID = TOP_COUNTRY.COD_CNTRY)");
    When I add double quotes around the databaseName, I get to line 8 but then I get an error:
    com.sybase.jdbc3.jdbc.SybSQLException: ASA Error -141: Table 'TOP_IDENTITY' not found
    But the table is again, definitely there ...
    I've tried escaping it by replacing & with &amp;
    But no luck.

    1) What version and build are you running for jConnect and SQL Anywhere?
    I’ve used jconn2 and jconn3, for the moment I’m using 3
    SQL Anywhere = 9.0.2.3198 on my developer system
    2) Can you post the output from dbinfo for the database that you testing?
    I'm assuming you mean this:
    Adaptive Server Anywhere Database Engine Version 9.0.2.3198
    Copyright © 1989-2004 Sybase, Inc.
    Portions Copyright © 2002-2004, iAnywhere Solutions, Inc.
    All rights reserved. All unpublished rights reserved.
    This software contains confidential and trade secret information of
    iAnywhere Solutions, Inc.
    Use, duplication or disclosure of the software and documentation
    by the U.S. Government is subject to restrictions set forth in a license
    agreement between the Government and iAnywhere Solutions, Inc. or
    other written agreement specifying the Government's rights to use the
    software and any applicable FAR provisions, for example, FAR 52.227-19.
    iAnywhere Solutions, Inc., One Sybase Drive, Dublin, CA 94568, USA
    4 logical processor(s) on 1 physical processor(s) detected.
    Running on Windows NT 6.1 Build 7601 Service Pack 1
    21688K of memory used for caching
    Minimum cache size: 2048K, maximum cache size: 262144K
    Using a maximum page size of 8192 bytes
    Database server started at Wed Aug 27 2014 14:18
    Trying to start SharedMemory link ...
        SharedMemory link started successfully
    Trying to start NamedPipes link ...
        NamedPipes link started successfully
    Trying to start TDS (TCPIP) link ...
    Starting on port 2638
        TDS (TCPIP) link started successfully
    Now accepting requests
    Starting database "TOPADMINSA9" (W:\TOP\DATA\TOPADMINSA9.db) at Wed Aug 27 2014 14:18
    Transaction log: TOPADMINSA9.log
    Starting checkpoint of "TOPADMINSA9" (TOPADMINSA9.db) at Wed Aug 27 2014 14:18
    Finished checkpoint of "TOPADMINSA9" (TOPADMINSA9.db) at Wed Aug 27 2014 14:18
    Database "TOPADMINSA9" (TOPADMINSA9.db) started at Wed Aug 27 2014 14:18
    Starting database "3051" (w:\TOP\DATA\3051\3051.DB) at Wed Aug 27 2014 14:18
    Starting checkpoint of "3051" (3051.DB) at Wed Aug 27 2014 14:18
    Finished checkpoint of "3051" (3051.DB) at Wed Aug 27 2014 14:18
    Database "3051" (3051.DB) started at Wed Aug 27 2014 14:18
    Starting database "BANDENM&W" (w:\TOP\DATA\BANDENM&W\BANDENM&W.DB) at Wed Aug 27 2014 14:19
    Database "3051" (3051.DB) stopped at Wed Aug 27 2014 14:19
    Starting checkpoint of "BANDENM&W" (BANDENM&W.DB) at Wed Aug 27 2014 14:19
    Finished checkpoint of "BANDENM&W" (BANDENM&W.DB) at Wed Aug 27 2014 14:19
    Database "BANDENM&W" (BANDENM&W.DB) started at Wed Aug 27 2014 14:19
    Starting database "BRAL" (w:\TOP\DATA\BRAL\BRAL.DB) at Wed Aug 27 2014 14:19
    Transaction log: w:\TOP\DATA\BRAL\BRAL.log
    Starting checkpoint of "BRAL" (BRAL.DB) at Wed Aug 27 2014 14:19
    Finished checkpoint of "BRAL" (BRAL.DB) at Wed Aug 27 2014 14:19
    Database "BRAL" (BRAL.DB) started at Wed Aug 27 2014 14:19
    Starting checkpoint of "BRAL" (BRAL.DB) at Wed Aug 27 2014 14:19
    Finished checkpoint of "BRAL" (BRAL.DB) at Wed Aug 27 2014 14:19
    Database "BRAL" (BRAL.DB) stopped at Wed Aug 27 2014 14:19
    Starting database "HARKELIJN" (w:\TOP\DATA\HARKELIJN\HARKELIJN.DB) at Wed Aug 27 2014 14:19
    Transaction log: w:\TOP\DATA\HARKELIJN\HARKELIJN.log
    Starting checkpoint of "HARKELIJN" (HARKELIJN.DB) at Wed Aug 27 2014 14:19
    Finished checkpoint of "HARKELIJN" (HARKELIJN.DB) at Wed Aug 27 2014 14:19
    Database "HARKELIJN" (HARKELIJN.DB) started at Wed Aug 27 2014 14:19
    Starting checkpoint of "HARKELIJN" (HARKELIJN.DB) at Wed Aug 27 2014 14:19
    Finished checkpoint of "HARKELIJN" (HARKELIJN.DB) at Wed Aug 27 2014 14:19
    Starting database "BURO56" (w:\TOP\DATA\BURO56\BURO56.DB) at Wed Aug 27 2014 14:19
    Database "HARKELIJN" (HARKELIJN.DB) stopped at Wed Aug 27 2014 14:19
    Transaction log: w:\TOP\DATA\BURO56\BURO56.log
    Starting checkpoint of "BURO56" (BURO56.DB) at Wed Aug 27 2014 14:19
    Finished checkpoint of "BURO56" (BURO56.DB) at Wed Aug 27 2014 14:19
    Database "BURO56" (BURO56.DB) started at Wed Aug 27 2014 14:19
    Starting checkpoint of "BURO56" (BURO56.DB) at Wed Aug 27 2014 14:19
    Finished checkpoint of "BURO56" (BURO56.DB) at Wed Aug 27 2014 14:19
    Database "BURO56" (BURO56.DB) stopped at Wed Aug 27 2014 14:19
    Starting database "ENOZEN" (w:\TOP\DATA\ENOZEN\ENOZEN.DB) at Wed Aug 27 2014 14:19
    Transaction log: w:\TOP\DATA\ENOZEN\ENOZEN.log
    Starting checkpoint of "ENOZEN" (ENOZEN.DB) at Wed Aug 27 2014 14:19
    Finished checkpoint of "ENOZEN" (ENOZEN.DB) at Wed Aug 27 2014 14:19
    Database "ENOZEN" (ENOZEN.DB) started at Wed Aug 27 2014 14:19
    Starting checkpoint of "ENOZEN" (ENOZEN.DB) at Wed Aug 27 2014 14:19
    Finished checkpoint of "ENOZEN" (ENOZEN.DB) at Wed Aug 27 2014 14:19
    Database "ENOZEN" (ENOZEN.DB) stopped at Wed Aug 27 2014 14:19
    Starting database "ENOCONBVBA" (W:\TOP\DATA\ENOCONBVBA\ENOCONBVBA.DB) at Wed Aug 27 2014 14:19
    Transaction log: W:\TOP\DATA\ENOCONBVBA\ENOCONBVBA.LOG
    Starting checkpoint of "ENOCONBVBA" (ENOCONBVBA.DB) at Wed Aug 27 2014 14:19
    Finished checkpoint of "ENOCONBVBA" (ENOCONBVBA.DB) at Wed Aug 27 2014 14:19
    Database "ENOCONBVBA" (ENOCONBVBA.DB) started at Wed Aug 27 2014 14:19
    Starting checkpoint of "ENOCONBVBA" (ENOCONBVBA.DB) at Wed Aug 27 2014 14:19
    Finished checkpoint of "ENOCONBVBA" (ENOCONBVBA.DB) at Wed Aug 27 2014 14:19
    Database "ENOCONBVBA" (ENOCONBVBA.DB) stopped at Wed Aug 27 2014 14:19
    3) Can you run the following queries within the application that you are seeing this behavior and provide the results:
      Q1:
         select  user_name,  table_name
              from  systable join sysuser
         where
               table_name in ('TOP_IDENTITY','TOP_COUNTRY')
    27-08-14 14:23:30 [ERROR] TechLogger -  -> com.sybase.jdbc3.jdbc.SybSQLException: ASA Error -141: Table 'sysuser' not found
    Q2:
         select current user from dummy;
    resultSet2.getString("current user")" = DBA

  • Casting string to a class type

    is it possible to typecast a string to a classtype?
    Example:
    if a string is stored in a vector v and xyz is a class then is the following statement correct :
    ((xyz)v.elementAt[2]) ??
    if not then what should i do to typecast it?

    Navy_Coder wrote:
    jverd wrote:
    Navy_Coder wrote:
    streetfi8er wrote:
    is it possible to typecast a string to a classtype?
    Example:
    if a string is stored in a vector v and xyz is a class then is the following statement correct :
    ((xyz)v.elementAt[2]) ??
    if not then what should i do to typecast it?Do you understand what typecasting is? What you're asking could be compared to taking your truck to a mechanic and asking if they can just turn it into a banana. You can't cast one object to another completely unrelated object.In fact, you can't cast objects at all.On second thought ......
    enum Destination {
    ETERNAL_DAMNATION, PITS_OF_HELL, OCEAN, VAT_OF_ACID;
    ObjectManager.cast(myInstance, Destination.PITS_OF_HELLO);
    ObjectManager.cast(calebsBrain, Destination.VAT_OF_ACID);
    IMHO, this is still casting a reference, not an object.

Maybe you are looking for

  • GS60-2QE (970M) Stuck at MSI Splash Screen

    Evening all, Just went to use my laptop and I'm stuck at the MSI splash screen. I can't get to the BIOS or anything. I haven't ever dropped it and it's always handled with care. Last night it was last used and has been working totally fine up until n

  • IPod won't sync, neither music nor update

    Hey all, So i've got a 32GB iPod Touch 4g running 4.3.5 (8L1). Every time I try to update it on my computer, it won't work (laptop running OS X Lion and iTunes 10.5); It constantly tells me that my iPod is ineligible for the selected build. Additiona

  • Final Cut Studio Installation Problems

    Firstly, the specs: 2.8ghz 8-core Mac Pro, 2GB RAM, nVidia 8800GT, 10.5.2 The problem: I am installing FCS1 for the first time ever and am having difficulties installing some parts of it before the Mac Pro reboots on its own. Sometimes I'll finish a

  • When i receive notification on any software there is no sound at all

    please help me when i get any messages on facebook or whatsup or any software i dont get any sound that i recieved any messges or notification

  • I cannot save an image that I have resized in Preview version 7.0

    When I resize any image in Preview version 7.0 I get an error that says I cannot save it.  This happens with jpg, tiff, png, etc. and I have attempted to save to my desktop and other locations to no avail.  Is anyone else having this problem and how