Output of int value to char

hi,
I have written the following code
class LiteralTest
     public static void main(String[] args)
          System.out.println("Hello World!");
          int true1=100;
          float flt = 17.2345678f;
          short sh = (int)500;
          char a=0x892;
          char b=982;
          char c=(char)70000;
          char d=(char)-98;
          System.out.println(a + " -- "+b+ " -- "+c+ " -- "+d);
the output is
Hello World!
Please explain why the values are '?' and not the actual values?
Deepali

And why are you specifying a character with a
negative number?Casting a negative number to a (unicode) char is valid. For example
            int c = -1279;
            System.out.println(c);           
            char ch = (char)c;
            System.out.println(ch);prints the 'fi' character which has unicode value 0xfb01.

Similar Messages

  • USB Output Buffers - int to Hexed Chars

    Hi all
    With regards sending data to a USB device I set up a char like so:
    size_t bufferSize = 8;
    char *buffer = malloc(bufferSize);
    I can then populate my bytes in hex (which seems to be the normal way of doing it).
        buffer[0] = 0xFF;
        buffer[1] = 0xEA;
    The two fold question is will I have any issues if i populate the char buffers with integers?
        int value = 256;
        buffer[0] = value;
    or does it have to be in hex?
    If it requires hex (or even if not cos it would be good to know). What the best way to convert and integer to a hexed char?
    Cheers
    Steve

    It doesn't matter if you specify the value in hexadecimal, decimal, octal or binary (or any other numbering system for that matter).
    A number has the same value no matter what base you use.

  • Getting int values from a char array

    Hi,
    I need to make a fast program which reads lots of data from files and process them. I need to interpret these data as int's. To be more efficient and avoid to make a lot of disk access, I allocate in memory buffers part of the data, then process it and then allocate new data. The problem is that if I want to allocate data in memory buffers, all the methods that enables me to do that receceive as a parameter only a an array of chars, and as I have mentioned I need to interpret the data as a 4 bytes int. The static methods of Array to get the int value from a position ar not useful because the onlye get the int value of the indexed byte (or char); this method doesn't take 4 bytes from the index to build an int.
    My question is: is there any way to build an int from 4 bytes? or can I get the int's in this way directly from the buffer?
    Thank you,

    Isn't this one of the prime examples of using java.io.DataOutputStream and java.io.DataInputStream?

  • HOW can I convert int value char TO String

    I am trying to study Java by books, but sometimes it is quite difficult to find answers even to simple questions...
    I am writing a program that analyzes a Chinese text in Unicode. What I get from the text is CHAR int value (in decimals), and now I need to find them in another text file (with RegEx). But I can't find a way how to convert an INT value of a char into a String.
    Could you help me?
    Thank you in advance.

    You are confusing matters a bit. A char is a char is a char, no matter
    how you represent it. Have a look at this:char a= 'A';
    char b= 65;Both a and b have the same value. The representation of that value
    can be 'A' or 65 or even (char)('B'-1), because the decimal representation
    of 'B' is 66. Note the funny construct (char)(...). This construct casts
    the value ... back to the char type. Java performs all non-fraction
    arithmetic using four byte integers. The cast transforms it back to
    a two byte char type.
    Strings are just concatenations of zero or more chars. the charAt(i)
    method returns you the i-th char in a string. Have a look:String s= "AB";
    char a= 'A';
    char b= (char)(a+1);
    if (a == s.charAt(0)) System.out.println("yep");
    if (b == s.charAt(1)) System.out.println("yep");This piece of code prints "yep" two times. If you want to compare two
    Strings instead, you have to do this:String s= "AB";
    char a= 'A';
    char b= 'B';
    String t= ""+a+b;
    if (s.equals(t)) System.out.println("yep");Note the 'equals' method instead of the '==' operator. Also note that
    string t was constructed using those two chars. The above was a
    shorthand of something like this:StringBuffer sb= new StringBuffer("");
    sb.append(a);
    sb.append(b);
    String t= sb.toString();This is all handled by the compiler, for now, you can simply use the '+'
    operator if you want to append a char to a string. Note that it is not
    very efficient, but it'll do for now.
    Does this get your started?
    kind regards,
    Jos

  • Putting float/int values in xml document

    I am using Oracles XML Parser for C (ver 9i). I have a float or int value which i want to put in the xml document that I am creating. The part of the code is as below..
    char str_l[50];
    float height_l;
    elem_l = createElement(ctx_i, (oratext *)"HEIGHT");
    if (!appendChild(ctx, parent_l, elem_l))
    printf("Error Creating Element\n");
    return FAILURE;
    parent_l = elem_l;
    height_l = 15.7;
    sprintf(str_l, "%f", height_l);
    elem_l = createTextNode(ctx_i, str_l);
    if (!appendChild(ctx, parent_l, elem_l) )
    printf("Error Creating Element\n");
    return FAILURE;
    This put 0.00000 as the value of height in the document. ie the o/p is
    <HEIGHT>0.00000</HEIGHT>
    Can anyone help me out with this.
    Thanks and regards
    Umesh

    I am using Oracles XML Parser for C (ver 9i). I have a float or int value which i want to put in the xml document that I am creating. The part of the code is as below..
    char str_l[50];
    float height_l;
    elem_l = createElement(ctx_i, (oratext *)"HEIGHT");
    if (!appendChild(ctx, parent_l, elem_l))
    printf("Error Creating Element\n");
    return FAILURE;
    parent_l = elem_l;
    height_l = 15.7;
    sprintf(str_l, "%f", height_l);
    elem_l = createTextNode(ctx_i, str_l);
    if (!appendChild(ctx, parent_l, elem_l) )
    printf("Error Creating Element\n");
    return FAILURE;
    This put 0.00000 as the value of height in the document. ie the o/p is
    <HEIGHT>0.00000</HEIGHT>
    Can anyone help me out with this.
    Thanks and regards
    Umesh

  • Get every 10 sec a int.value and need to take the sum of the last 18 values

    Hi,
    i get every 10 sec a int.value and need to take the sum of the last 18 values (3 minutes).
    the programm should work permanently.
    I tried with a 1d-array but didn´t get a result. Could anyone help me?
    Best regards
    kasche

    Use the example in the posted link, then add another shift register for your sum of all elements. Dont add all the elements every time, add them to a running total when they come in. You will need to evaluate how big this number is going to get, however, and decide if you should use an I64 for your running total of all elements. Even this will overflow eventually. 
    So your code would look like that posted by GerdW in the above link, then add a shift register with a starting value of 0. Then add your input value to the value comming from this shift register and send the output to the shift register's output terminal. This creates your running total of all values. The code by GerdW provides your "last 18 elements" total in a very efficient manner, just change the 15 to an 18.
    I have attached a sample bit of code to make it clear. I saved it in LV 8.0 so more people can open it.
    CyberTazer
    Software Systems Engineer
    Attachments:
    Running 18 total.vi ‏11 KB

  • How to get Int value from request.getParameter()?

    Hi all,
    I have a integer value which is passed from one page to another page.
    i am geting this value in the next page using
    request.getParameter().
    Eg.
    Suppose value of "i" in page1 is 32, i pass this as hidden variable to next page.
    <input type="hidden" Value="<%=i%>" NAME="limit">
    in page2, i fethch this value to a variable by name "limit"
    String limit=request.getParameter("limit");
    but, since value stored in limit is int, i can't assign it to string.
    i can't use request.getParameter for int values.
    How to solve my problem.
    I know it is simple,
    Pls. help me
    Regards
    ASh
    String limit=request.getParameter("limit");

      String limitSTR = request.getParameter("limit");
      int limit = -1;
      if (limitSTR != null) limit = Integer.parseInt(limitSTR);

  • How to get int value from [session.getAttribute("String")]

    i am not able to get int value from the following statiment
    int i=session.getAttribute("String");
    i also try by casting it into int but it dont work, can somebody help me in this regard

    abuu wrote:
    i am not able to get int value from the following statiment
    int i=session.getAttribute("String");
    i also try by casting it into int but it dont work, can somebody help me in this regard
    Integer i=(Integer)session.getAttribute("String");
    i.intValue();but know how it is working. that is useful.
    Diablo.

  • How do I know if I can convert a String value to an int value or not?

    Hi,
    I want to know how to make the judgment that if I can convert a String value to an int value or not? Assume that I don't know the String is number or letters
    Thank you

    Encephalopathic wrote
    Again, why?One of the problems (have been dued) in my codelab asks us to write a class as follow
    Write a class definition of a class named 'Value' with the following:
    a constructor accepting a single integer paramter
    a constructor with no parameters
    a method 'setVal' that accepts a single parameter,
    a boolean method, 'wasModified' that returns true if setVal was ever called for the object.
    a method 'getVal' that returns an integer value as follows: if setVal has ever been called, it getVal returns the last value passed to setVal. Otherwise if the "single int parameter" constructor was used to create the object, getVal returns the value passed to that constructor. Otherwise getVal returns 0.
    The setVal(int y) returns nothing, so how do I know whether it has been called or not?
    Thank you

  • How to Convert a HEX value to CHAR value...Unicode Issue...

    Hi,
    How can I convert HEX value to CHAR value.
    The Code in <b>non Unicode</b> system is:
    DATA: t_text LIKE tline OCCURS 0 WITH HEADER LINE.
    constants:   c_hex_20a5(2) TYPE x            VALUE '20A5'.
    t_text-tdline = 'seller of the item so listed.  A legend of the Seller Code(s) is as'.
          TRANSLATE t_text-tdline USING c_hex_20a5.
    The same code give error in <b>Uni-Code</b> system:
    <b>error is "c_hex_20a5 must be an character type object (C, N, D, T or String type)."</b>
    If anyone know, what is the solution, please let me know.
    Thanks!
    Puneet.

    Hi,
    Try declaring the Hex chars using the ABAP char utilities. This is just a sample piece of code on how to declare and use:
    CLASS cl_abap_char_utilities DEFINITION LOAD.
    DATA:  ws_lf TYPE c VALUE cl_abap_char_utilities=>cr_lf.
    data:    c_newline           TYPE x VALUE '0D'.  [ it is zero D, for carriage return ]
    ws_lf = c_newline.
        CONCATENATE it_tab-maktx
                    ws_lf
                    ws_template
                    INTO it_notificatn-template.
    Hope this helps...
    Regards
    Subramanian

  • Outputting an int variable in an applet?

    Hey all i will keep this short, i am modifying an applet for a university project and am trying to output an integer variable to screen, i tried using g.drawString but i apparently can only use it to output "text in the double quotes" and if i try putting the variable in without the double quotes it throws an error, i was just wondering how would you output a int variable to screen in an applet, thanks

    To convert an int to a String, use:
    String.valueOf(int)

  • Comparing a single int to more than one int value?

    Hi is there a way to compare a single int value amongst several ints in one go?
    i know i could do if statements that can compare each int one by one but i was wondering if there is an easier way? like comparing all values amognst eachother
    somthing like
    int i;
    int a,b,c,d,e,f,,g;
    //ints a-g assigned some random numbers
    if(i == a,b,c,d,e,f,g)
          //do somthing here
    }

    i found out a way. i tried this way by using nested for loops and an if statement that compares every single value amongst eachother
    for(int q=0; q < 5; q++)
                ran[q] = (int)(java.lang.Math.random()*52);
            for(int x = 0; x < 5;x++)
                for(int z = 0; z < 5; z++)
                    if(x != z && ran[x] == ran[z])
                        ran[x] = (int)(java.lang.Math.random()*52);
            }

  • I want to create stored procedure which will give output rows from "values that are passed as one parameter (comma seperated) to store procedure".

    Hello,
    I want to create stored procedure which will give output rows from "values that are passed as one parameter (comma seperated) to store procedure".
    Suppose , 
    Parameter value : person 1,person2,person3 
    table structure : 
    Project Name | officers 1 | officers 2
    here, officers 1 or officers 2 may contain names of multiple people.
    expected OUTPUT : distinct list(rows) of projects where person 1 or person 2 or person 3 is either officer1 or officer 2. 
    please explain or provide solution in detail 
    - Thanks

    Hi Visakh,
    Thanks for reply.
    But the solution you provided giving me right output only if officer 1 or officer 2 contains single value , not with comma seperated value.
    Your solution is working fine for following scenario : 
    Project 
    Officers 1
    Officers 2
    p1
    of11
    off21
    p2
    of12
    off22
    with parameter : of11,off22 : it will give expected output
    And its not working in case of :
    Project 
    Officers 1
    Officers 2
    p1
    of11,of12
    off21,off23
    p2
    of12,of13
    off22,off24
    with parameter : of11,off22 : it will not give any row in output
    I need patten matching not exact match :) 
    ok
    if thats the case use this modified logic
    CREATE PROC GetProjectDetails
    @PersonList varchar(5000)
    AS
    SELECT p.*
    FROM ProjectTable p
    INNER JOIN dbo.ParseValues(@PersonList,',')f
    ON ',' + p.[officers 1] + ',' LIKE '%,' + f.val + ',%'
    OR ',' + p.[officers 2] + ',' LIKE '%,' + f.val + ',%'
    GO
    Keep in mind that what you've done is a wrong design approach
    You should not be storing multiples values like this as comma separated list in a single column. Learn about normalization . This is in violation of 1st Normal Form
    Please Mark This As Answer if it solved your issue
    Please Mark This As Helpful if it helps to solve your issue
    Visakh
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Output only numeric values

    CREATE TABLE XYZ( A1 VARCHAR2(10));
    Inserting value in table
    SELECT * FROM XYZ;
    A1
    1
    999
    45
    $
    ^
    +
    =
    How get output only numeric values ?

    Hmm..
    satyaki>
    satyaki>select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    PL/SQL Release 10.2.0.1.0 - Production
    CORE    10.2.0.1.0      Production
    TNS for Linux: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    Elapsed: 00:00:00.01
    satyaki>
    satyaki>
    satyaki>CREATE TABLE XYZ( A1 VARCHAR2(10));
    Table created.
    Elapsed: 00:00:00.07
    satyaki>
    satyaki>insert into XYZ values('&val');
    Enter value for val: 1
    old   1: insert into XYZ values('&val')
    new   1: insert into XYZ values('1')
    1 row created.
    Elapsed: 00:00:00.00
    satyaki>/
    Enter value for val: 999
    old   1: insert into XYZ values('&val')
    new   1: insert into XYZ values('999')
    1 row created.
    Elapsed: 00:00:00.00
    satyaki>/
    Enter value for val: 45
    old   1: insert into XYZ values('&val')
    new   1: insert into XYZ values('45')
    1 row created.
    Elapsed: 00:00:00.00
    satyaki>/
    Enter value for val: !
    old   1: insert into XYZ values('&val')
    new   1: insert into XYZ values('!')
    1 row created.
    Elapsed: 00:00:00.00
    satyaki>/
    Enter value for val: @
    old   1: insert into XYZ values('&val')
    new   1: insert into XYZ values('@')
    1 row created.
    Elapsed: 00:00:00.00
    satyaki>/
    Enter value for val: $
    old   1: insert into XYZ values('&val')
    new   1: insert into XYZ values('$')
    1 row created.
    Elapsed: 00:00:00.00
    satyaki>/
    Enter value for val: #
    old   1: insert into XYZ values('&val')
    new   1: insert into XYZ values('#')
    1 row created.
    Elapsed: 00:00:00.00
    satyaki>/
    Enter value for val: ^
    old   1: insert into XYZ values('&val')
    new   1: insert into XYZ values('^')
    1 row created.
    Elapsed: 00:00:00.00
    satyaki>/
    Enter value for val: &
    old   1: insert into XYZ values('&val')
    new   1: insert into XYZ values('&')
    1 row created.
    Elapsed: 00:00:00.00
    satyaki>/
    Enter value for val: *
    old   1: insert into XYZ values('&val')
    new   1: insert into XYZ values('*')
    1 row created.
    Elapsed: 00:00:00.00
    satyaki>/
    Enter value for val: (
    old   1: insert into XYZ values('&val')
    new   1: insert into XYZ values('(')
    1 row created.
    Elapsed: 00:00:00.00
    satyaki>/
    Enter value for val: )
    old   1: insert into XYZ values('&val')
    new   1: insert into XYZ values(')')
    1 row created.
    Elapsed: 00:00:00.00
    satyaki>/
    Enter value for val: -
    old   1: insert into XYZ values('&val')
    new   1: insert into XYZ values('-')
    1 row created.
    Elapsed: 00:00:00.00
    satyaki>/
    Enter value for val: +
    old   1: insert into XYZ values('&val')
    new   1: insert into XYZ values('+')
    1 row created.
    Elapsed: 00:00:00.00
    satyaki>/
    Enter value for val: =
    old   1: insert into XYZ values('&val')
    new   1: insert into XYZ values('=')
    1 row created.
    Elapsed: 00:00:00.00
    satyaki>
    satyaki>commit;
    Commit complete.
    Elapsed: 00:00:00.00
    satyaki>
    satyaki>
    satyaki>select * from XYZ;
    A1
    1
    999
    45
    $
    ^
    A1
    +
    =
    15 rows selected.
    Elapsed: 00:00:00.01
    satyaki>
    satyaki>
    satyaki>
    satyaki>select * from XYZ
      2     where regexp_like(A1,'[[:digit:]]');
    A1
    1
    999
    45
    Elapsed: 00:00:00.00
    satyaki>
    satyaki>Regards.
    Satyaki De.

  • Mapping a key string to the KeyEvent int value

    /** Returns the int value of a key
    * @param the String representing the key. example "SHIFT" for the shift key
    * @return KeyEvent.VK_keyName
    public static int mapKeyCode(String keyName) {
    // we don't have access to an instance of KeyEvent!!!
    Class.forName("java.awt.event.KeyEvent").getDeclaredField("VK_"+keyName).getInt(obj..@#@#@
    //+ exception handling
    }

    public int keyTyped( KeyEvent event ) {
      try {
         return java.lang.Integer( String.valueOf( event.getKeyChar() ) );
      } catch ( NumberFormatException nfe ) {
         System.err.println( "NumberFormatException: " + nfe.getMessage() );
         return( 0 );
    }

Maybe you are looking for

  • Satellite L20-182: fan doesn't work properly - one minute intervals

    When I turn on the computer about twenty minutes is quiet. Than fan starts like a hurricane, slows down and stops. It lasts few seconds. The fan works in this way regularly with one minute intervals. Is there any possibility to switch the fan on cont

  • Can't create Connection to Oracle Database

    Hi i'm trying to create a simple connection to my oracle database and my projects compiles, but at the "createConnection" statement an SQLException is thrown. Well first of all my stats: Windows XP 32 bit Visual Studio 2005 (VC++ 8) Oracle Database 1

  • Report showing "Confirmed" and "Unconfirmed" Schedule Lines for SA's

    Hi Experts! I had an issue regarding our scheduling agreements. Issue is below: Open Order Report only shows the "unconfirmed" schedule lines...Is there any way or a report that will show the "confirmed" schedule lines as well? This is an urgent matt

  • Need maximum information about Content Management in Weblogic Portal 10.3

    Hi, I have worked with Weblogic Portal before, but it's been some time, I do not remember much and I quickly need to find some info. We are making a proposal to a customer and have suggested Weblogic Portal. I would like to give as much information a

  • Load layout according to User Id

    Hi Gurus , I made an ALV and i want to load specific layouts according to the user that running the report. For example ... When User1   load the layout   /layout1 at start. When User2   load the layout   /layout2 at start. Can i do this . Thanks a l