How do I convert the unicode into an int?

I have to take a large integer from user and put each digit into an array. To take the large number I use .nextLine() so that I would be stored as a string. Then I put each digit into an array of type int, and I use implicit type casting to convert each character to an int. The problem is that now the array contains the unicode for the number, how do I get the actual number?
I know this is kind of silly not to use bigInteger but that's part of the assignment.
better yet, the array mas as well be of bytes since no digits Unicode goes above 57
Edited by: bean-planet on Oct 31, 2008 1:12 PM

So your character is '1' and when you cast that to an int you get something like 49? And you want 1 instead? If that's the case then don't cast, use Character.getNumericValue('1') instead. But read the documentation for the method so you don't get surprised at what Character.getNumericValue("L") returns, for example.

Similar Messages

  • How can I convert a String into an int?

    I need to use command-line args. So I enter "java Main 123" and I want to use 123 not as a String but as an int.
    How can I convert it into an int?
    Thank You!!
    Sprocket

    Example method (you don't need to use a method unless you do this a lot)
    private int stringTOInt (String aString)
    int result = 0;
    try
    result = Integer.parseString(aString);
    catch (Exception ex)
    System.out.println ("Failed to convert string " + aString + " to int.");
    return result;
    }

  • How can i convert the program into modular programming?

    public class number{
         public static void main(String args[])throws Exception{
              int num,lb,ub,range,i=0,sum=0,hold,times1=0,j;
              System.out.print("Lower Bound:");
              lb=Keyboard.readInt();
              System.out.print("Upper Bound:");
              ub=Keyboard.readInt();
              range=ub-lb;
              System.out.print("How many number you want to display?");
              num=Keyboard.readInt();
              int[] count=new int[num];     
              System.out.print("The number between "+lb);
              System.out.print(" and "+ub);
              System.out.println(" are: ");
              for(i=0;i<num;i++)
                   count=(int)(Math.random()*range+lb);
                   System.out.println(count[i]);
                   sum=count[i]+sum;                    
              System.out.println("The total is "+sum);
              for (int pass=1;pass<count.length;pass++)
              for(i=0;i<count.length-1;i++) // a single pass
              if(count[i] > count[i+1]) {
              hold = count[i]; // swap elements
              count[i] = count[i+1];
              count[i+1] = hold;
         System.out.println("Data after sorting:");
         for(i=0;i<count.length;i++){
         System.out.println(count[i]);
         System.out.println("***Frequency of the number***");
         for(i=0;i<=count.length-1;i++){
              int times=1;
              for(j=i+1;j<count.length;j++)
                   if(count[i]==count[j])
                        times=times+1;                                             
         System.out.print(count[i]);
         System.out.print(" = ");
         System.out.println(times+" times");
              if(i!=1)
                   times1=times-1;
              if(i>0){
                   times1=times+i-1;          
              i=times1;
         System.out.println("");
         int up,low;
         System.out.println("***Key in the range***");
         System.out.print("Lower Bound : ");
         low=Keyboard.readInt();
         System.out.print("Upper Bound : ");
         up=Keyboard.readInt();
         for(i=0;i<num;i++){
              int times=1;
              for(j=i+1;j<num;j++){
                   if(count[i]==count[j])
                   times=times+1;
         if((count[i]>=low)&&(count[i]<=up))
                   System.out.println(count[i]);          
         if(i!=1){times1=times-1;}
         if(i>0){times1=times+i-1;}
         i=times1;
    here are my program.
    please help me to convert it into modular program by using below method and constructor.
    1)valueIn():fill in the array by generating random number between given range.range is given by user.
    2)valueOut(): to display all the value in the array.
    3)total():calculate total of all the value in an array.
    4)arrange():sort the number.
    5)findOur():to display the frequency of the number.
    6)rangeOut():user give a range aggain to display all the number between the given range.

    Idon't think it is fair to have us do what looks to be your homework. The problem is fairly simple, why not take a stab at it and let us comment on it?
    Chuck

  • How can i convert 3d movie into 2d to watch it in mac

    i have a movie with mkv file playable on vlc how can i convert the movie into 2d

    There are now a bunch of them out there. Do a Google search for "mac 3D conversion" They tend to be around $35. I have been using iSkysoft products, which have been fairly easy to use. They have a "iMedia Converter Deluxe for Mac" that besides the 3D to 2D conversion, will also convert video to 70+ formats, has a 1-Click Video Downloader, and a single click Rip DVD and Burn to DVDs feature. Also claims to be "Ultrafast" all for the same price others apps are that only do the conversion.

  • How can I convert the ringtone (m4r file) I made into an mp3 file on itunes?

    How can I convert the ringtone (m4r file) that I made into an mp3 file on iTunes? I want to put it on a CD, but I can't figure out how to convert it. I didn't buy it, I made it by converting a YouTube video into an mp3 (I wanted to get the little song in the video for a ringtone.) I'm not sure what to do. 

    Hello ed2345,
    Thanks for the help, but this is not the problem.
    It's hard to describe the problem, but I'll try it again, this time with pictures.
    I was left with the following folders in the iTunes Downloads folder.
    http://www.picfront.org/d/7yb3
    These TMP Folders have a download.m4a and a Info.plist file.
    After moving the audio files in iTunes a bit I get this.
    http://www.picfront.org/d/7yb2
    As you can see no other Information for the download.m4a than the length.
    That's how the .m4p file looks like
    http://www.picfront.org/d/7yb1
    And this is how the same .m4a file currently looks
    http://www.picfront.org/d/7yb0
    Like I said, I could edit all these download.m4a files by myself but that would leave some information out.
    Note: Sorry, I hope the links do not spam you with annoying ads. I don't get any but I was told that there can be some annoying one.

  • How can I convert the download.m4a and Info.plist into the right audio file

    The topic is actually the problem that I have.
    I have bought music and it was downloaded successful (all of it) but iTunes had a strange freeze while converting the files into the right audio file. Some files were converted but after the freeze no more.
    I'm now left with these .tmp folders in the downloads folder which have the download.m4a and Info.plist files.
    My iTunes is able to play these download.m4a files, but they show no information and covers and this is really annoying. I could write and change it all by myself, but than I would still miss some information (and covers).
    Is there any way for me to convert or combine these files?
    Note: I'm not able to restart any downloads, because they were successful.

    Hello ed2345,
    Thanks for the help, but this is not the problem.
    It's hard to describe the problem, but I'll try it again, this time with pictures.
    I was left with the following folders in the iTunes Downloads folder.
    http://www.picfront.org/d/7yb3
    These TMP Folders have a download.m4a and a Info.plist file.
    After moving the audio files in iTunes a bit I get this.
    http://www.picfront.org/d/7yb2
    As you can see no other Information for the download.m4a than the length.
    That's how the .m4p file looks like
    http://www.picfront.org/d/7yb1
    And this is how the same .m4a file currently looks
    http://www.picfront.org/d/7yb0
    Like I said, I could edit all these download.m4a files by myself but that would leave some information out.
    Note: Sorry, I hope the links do not spam you with annoying ads. I don't get any but I was told that there can be some annoying one.

  • How can I convert the volume directory into a single file installer?

    How can I convert the volume directory into a single file installer? I would like to hide all the miscillaneous files that I don't care for and be able to have the installer double click a single file and have it automatically install.

    On the second prompt screen when prompted 'What kind of self-extracting Zip file file do you want to make?'
    Are you choosing the second option (self-extracting Zip file for software installation)?
    I have a word file that I created to help me remember - is there anyway to email it to you?

  • How can i convert the firefox-history-timestamp in places.sqlite into a normal date format? The firefox-timestamp is not equivalent to the unix-timestamp, that's why I ask. I could not find a conversion function. Does anyone know something about this?

    As I opened the places.sqlite with an sqlite-editor I found out that firefox saves the last_visit_date via a timestamp which is 16 digits long. I realized that the first 10 digits are similar to the corresponding unix-timestamp but not equal. So.. how can i convert the firefox-timestamp into a normal date? Or into the corresponding unix-timestamp?

    Write a bash script or 'C' program to change the date format and then use the sql update function to receive the stdio output 'where date_field='embeded date value'.

  • I have an ipad 2 and want to put my dvds onto the ipad. i have converted the dvd into an mpeg4 file but cannot get it to open in i tunes does anyone know how i do this?

    i have an ipad 2 and want to put my dvds onto the ipad. i have downloaded handbrake and converted the file into mpeg4 file but i cannot get the file to open in itunes

    I have the same problem , i've converted my videos to mp4 , by using different programmes and tried to open them in itunes but it didnt .
    Some people suggested the following although it didnt help me , it might help you
    One suggested to paste the videos that you want in automatically add to itune (  go to your music folder m then click on itunes , then itunes media , and you will find it there )
    Others suggested to o to the ontrol panal , then programmes and features m then lick on quick time (. Or itunes) then Change then repair
    If it didnt help. And you find another method m please let me know
    Thank you

  • I need to convert PDF file to Word Document, so it can be edited. But the recognizing text options do not have the language that I need. How I can convert the file in the desired of me language?

    I need to convert PDF file to Word Document, so it can be edited. But the recognizing text options do not have the language that I need. How I can convert the file in the desired of me language?

    The application Acrobat provides no language translation capability.
    If you localize the language for OS, MS Office applications, Acrobat, etc to the desired language try again.
    Alternative: transfer a copy of content into a web based translation service (Bing or Google provides a free service).
    Transfer the output into a word processing program that is localized to the appropriate language.
    Do cleanup.
    Be well...

  • How can I convert DVD- video into Apple's format so that it can be played and streamed from my Mac?

    How can I convert DVD- video into Apple's format so that I can play the content on my Mac and also stream it to my Apple TV? A few years ago, I transferred all of my home videos onto DVD but now would really like to put these onto my Mac and stream them through Apple TV to watch on the "big screen". Any advice would be most welcome!! Thanks

    MPEG Streamclip.
    Apple do not have their "own" format. You need to convert your DVDs to H.264 though.

  • I have a 2 page PDF (portrait format), how can I convert the format to landscape?

    I have a 2 page (portaait format) PDF file how can I convert the PDF file into landscape format before I change it to XL?

    Hi jsremick,
    To change the page orientation of a PDF, you need to use Acrobat. (Reader allows you to rotate the page view, but not the pages  themselves).
    If you don't have Acrobat, feel free to give it a try. You can download the free 30-day trial from http://www.adobe.com/products/acrobat.html.
    Best,
    Sara

  • How do i convert a pdf into a word file, i have tried doing save as?

    how do i convert a pdf into a word file, i have tried doing save as?

    Hi Jack,
    What version of Acrobat are you using?
    You might need to go to File> Save As Other> Microsoft Word or choose 'Adobe PDF printer' from the File menu.
    Is save as option not functioning correctly? Do you get any specific error?
    Please let me know.
    Regards,
    Anubha

  • HT4059 How can I convert a pdf into an ibook?

    How can I convert a pdf into an ibook? I've got a host of PDF's that I'd like to bring into the software but need a quick and simple tool to pull them through. Any ideas?

    In the help of Acrobat look for Form.

  • How do I convert à PDF file into my dairy?

    How do I convert à PDF file into my dairy?

    If I understand whatnyounare asking (and not sure I do), you may have a difficult time accomplishing that. Calendar app doesn't store documents and I don 't know of an app that will extract text from a PDF and place it in a calendar entry automatically. Check the app store - I could be wrong - but you will have to handle that manually.
    Many apps that read PDF will allow you to copy text, including GoodReader mentioned above.

Maybe you are looking for

  • Executing a procedure in ADF model

    Dear All, I have created a new fusion web application in ADF, in that i have created a custom entity class that overrides doDML method. This is because i have to perform the insert, update and delete via stored procedure. But the problem is that i am

  • MM automatic account assignment for MIGO (additional accounting lines)

    Hi MM Experts! I created a PO (only 1 material in it), and after that I did a GR goods receipt in MIGO for this. Movement type: 101 When I did this the accounting lines looks like that: Itm PK Account    Account short text   Assignment...............

  • How to disable selectOneChoice depending on checkbox checked or not!?

    Hello guys, im new in ADF and i'm trying to print report about some workers. I pick up those workers from selectOneChoice. Then i want to have this option to print a report for all the workers. I use check box (all workers) and want to disable select

  • Anyone else having this problem? Region Editing problems, can't edit or see in editor.

    Hello, I'm using FCPX and i' having region issues, first of all i can't edit the region with the mouse as in pull it from the left or right to make it longer the whole region moves as if i clicked in the middle, then when i doucle click on it i'm not

  • I cannot find "scan for instrument​" at MAX

    Hi~ I connected GPIB-USB-HS cable between the laptop and Keithley 2602 device. In MAX, I could find GPIB-USB-HS "USB0::0x3923::0x709B::016F05B4::RAW" under "device&interface" However, I cannot find "scan for instrument" anywhere! So, I coudn't connec