Turning a primative double into a string

so, apparently
new String(2.3333434)
what ever doesnt allow me to make a string of the double
how can i go about doing this?
thx

String.valueOf(double)
Double.toString(double)
Learn to use the API docs. They're your friends, and friends are for using.

Similar Messages

  • How do you turn a List into a String?

    Hi,
    Have a simple question for all of you out there, hope you can help:
    How do you turn a list of words into a string?
    For example:
    List matchList = new ArrayList();
    matchList.add(word 1);
    matchList.add(word 2);
    matchList.add(word 3);
    String s = matchList(all of the words)How is this possible?

    but how would i go about doing that? Thats what i am
    askingIf you don't know how to iterate over a list, see this tutorial: http://java.sun.com/docs/books/tutorial/collections/If you don't know how to use StringBuffer, it should be somewhere in one of the links under Resources for Beginners at http://www.thejword.com/3.html#beginner_resources

  • How to store double quote into a string?

    How to store double quote into a string?
    What I mean is:
    suppose I want to save the following sentence into string s:
    What is the syntax?
    Thanks a lot!

    String s = "<a href=\"../jsp/Logout.jsp\">"
    check out this page
    http://java.sun.com/docs/books/tutorial/index.html
    Hope this helps

  • Can i turn a series of integers such as 1000-1200  into a string to check

    can i turn a series of integers such as 1000-1200 into a string to check positions with charAt I need to scan numers 1000-9999 to add the digits 1+0+0+0=1 or 9+9+9+9=36 to find the ones that when the result ie 36 is rased to the 4th power equal the original number? I want to scan charAt(position) then add those 4 positions.please help me
    heres my code so farpublic class Poweroffour
        public static void main(String[] args)
        int number;     
         String numberS;
        int numtotal;
         int numtotalpoweroffour;
         int num1;
         int num2;
         int num3;
         int num4;
         for (number=1000;number<10000;number++)
              numberS=number;
              num1=numberS.charAt(1);
              num2=numberS.charAt(2);
              num3=numberS.charAt(3);
              num4=numberS.charAt(4);
                 numtotal=num1+num2+num3+num4;
                 numtotalpoweroffour=numtotal*numtotal*numtotal*numtotal;
                 if (numtotalpoweroffour==number)
                      System.out.println(number);
        }}

    public class Poweroffour
        public static void main(String[] args)
            int numb=0;
             int thou=0;
            int hund=0;
            int tens=0;
            int ones=0;
            int total;
            int count;
           for (numb=1000;numb<10000;numb++)
                thou = numb/1000;
                hund = (numb -(thou *1000))/100;
                tens = ((numb % 100)- ones)/10;
                ones = numb % 10;
                System.out.println( thou + " " + hund + " " + tens + " " + ones);
    }          

  • Asking for directions - Transforming int // short // double into string

    I've been searching around the forums for a tutorial to transform an int or short or long back into a string, and I can't seem to find one. Could a kind person direct me to the tutorial for making integers into strings?

    String.valueOf(...)

  • How can I put all output error message into a String Variable ??

    Dear Sir:
    I have following code, When I run it and I press overflow radio button, It outputs following message:
    Caught RuntimeException: java.lang.NullPointerException
    java.lang.NullPointerException
         at ExceptionHandling.ExceptTest.actionPerformed(ExceptTest.java:72)
         at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
         at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
         at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
         at javax.swing.JToggleButton$ToggleButtonModel.setPressed(JToggleButton.java:291)
         at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
         at java.awt.Component.processMouseEvent(Component.java:6038)
         at javax.swing.JComponent.processMouseEvent(JComponent.java:3260)
         at java.awt.Component.processEvent(Component.java:5803)
         at java.awt.Container.processEvent(Container.java:2058)
         at java.awt.Component.dispatchEventImpl(Component.java:4410)
         at java.awt.Container.dispatchEventImpl(Container.java:2116)
         at java.awt.Component.dispatchEvent(Component.java:4240)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
         at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
         at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
         at java.awt.Container.dispatchEventImpl(Container.java:2102)
         at java.awt.Window.dispatchEventImpl(Window.java:2429)
         at java.awt.Component.dispatchEvent(Component.java:4240)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
         at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)Caught RuntimeException: java.lang.NullPointerException
         at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)I hope to catch all these error message into a String Variable such as StrErrorMsg, then I can use System.out.println(StrErrorMsg) to print it out or store somewhere, not only display at runtime,
    How can I do this??
    Thanks a lot,
    See code below.
    import java.awt.Frame;
    import java.awt.GridLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import java.io.FileInputStream;
    import javax.swing.ButtonGroup;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JRadioButton;
    public class ExceptTest extends JFrame implements ActionListener {
        private double[] a;
      private JRadioButton divideByZeroButton;
      private JRadioButton badCastButton;
      private JRadioButton arrayBoundsButton;
      private JRadioButton nullPointerButton;
      private JRadioButton negSqrtButton;
      private JRadioButton overflowButton;
      private JRadioButton noSuchFileButton;
      private JRadioButton throwUnknownButton;
      public ExceptTest() {
        JPanel p = new JPanel();
        ButtonGroup g = new ButtonGroup();
        p.setLayout(new GridLayout(8, 1));
        divideByZeroButton = addRadioButton("Divide by zero", g, p);
        badCastButton = addRadioButton("Bad cast", g, p);
        arrayBoundsButton = addRadioButton("Array bounds", g, p);
        nullPointerButton = addRadioButton("Null pointer", g, p);
        negSqrtButton = addRadioButton("sqrt(-1)", g, p);
        overflowButton = addRadioButton("Overflow", g, p);
        noSuchFileButton = addRadioButton("No such file", g, p);
        throwUnknownButton = addRadioButton("Throw unknown", g, p);
        getContentPane().add(p);
      private JRadioButton addRadioButton(String s, ButtonGroup g, JPanel p) {
        JRadioButton button = new JRadioButton(s, false);
        button.addActionListener(this);
        g.add(button);
        p.add(button);
        return button;
      public void actionPerformed(ActionEvent evt) {
        try {
          Object source = evt.getSource();
          if (source == divideByZeroButton) {
            a[1] = a[1] / a[1] - a[1];
          } else if (source == badCastButton) {
            Frame f = (Frame) evt.getSource();
          } else if (source == arrayBoundsButton) {
            a[1] = a[10];
          } else if (source == nullPointerButton) {
            Frame f = null;
            f.setSize(200, 200);
          } else if (source == negSqrtButton) {
            a[1] = Math.sqrt(-1);
          } else if (source == overflowButton) {
            a[1] = 1000 * 1000 * 1000 * 1000;
            int n = (int) a[1];
          } else if (source == noSuchFileButton) {
            FileInputStream is = new FileInputStream("Java Source and Support");
          } else if (source == throwUnknownButton) {
            throw new UnknownError();
        } catch (RuntimeException e) {
          System.out.println("Caught RuntimeException: " + e);
          e.printStackTrace();
          System.out.println("Caught RuntimeException: " + e);
        } catch (Exception e) {
          System.out.println("Caught Exception: " + e);
      public static void main(String[] args) {
        JFrame frame = new ExceptTest();
        frame.setSize(150, 200);
        frame.addWindowListener(new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
        frame.show();
    }

    yes, I update as follows,
    but not looks good.
    import java.io.*;
    public class UncaughtLogger implements Thread.UncaughtExceptionHandler {
        private File file;
        private static String errorMessage;
        public UncaughtLogger(File file) {
            this.file = file;
            //Thread.setDefaultUncaughtExceptionHandler(this);
        public UncaughtLogger(String str) {
            this.errorMessage = str;
            Thread.setDefaultUncaughtExceptionHandler(this);
        //@Override()
        public void uncaughtException(Thread t, Throwable e){
            try {
                log(e);
            } catch (Throwable throwable) {
                System.err.println("error in logging:");
                throwable.printStackTrace();
        private void log(Throwable e) throws IOException {
            PrintWriter out = new PrintWriter(new FileWriter(file, true));
            try {
                e.printStackTrace(out);
            } finally {
                out.close();
        private static UncaughtLogger logger = new UncaughtLogger(new File("C:/temp/log.txt"));
        private static UncaughtLogger logger2 = new UncaughtLogger(errorMessage);
        public static void main(String[] args) {
                String s1 = "Hello World!";
                s1 = null;
                String s2 = s1.getClass().getName();
                System.out.println(s1);
                System.out.println(s2);
                System.out.println("errorMessage =" + errorMessage);
    }

  • Re: cannot be applied to (double,java.lang.String)

    It's telling you what the problem is -- you're trying to pass a String in where a double is required. Java is a strongly typed language, which means that you can't expect types to change automatically into other types as needed.
    You could, I suppose, parse the string, assuming that it holds a representation of a double. But if you look at the method in question, you'll see that it doesn't even use its second (double) argument.
    So you should ask yourself:
    1) should that method really take two arguments?
    2) what is the second argument for, if I did use it?
    3) what is the best type to represent the second argument?
    (hint: with a name like "customerType", then an enum seems likely)
    [add]
    Too slow again.
    Though I'll also add: please wrap any code you post in [code][/code] tags. It makes your code much easier to read.
    Message was edited by:
    paulcw

    >  String n ;
    n = JOptionPane.showInputDialog(null, "Enter Month No.:");
    pow(double,double) in java.lang.Math cannot be
    applied to (double,java.lang.String)Read the error diagnostic carefully: the compiler found a pow() method
    in the Math class, but it takes two doubles as its arguments. You,
    however, supplied a double and a String as the parameter types.
    The method found by the compiler cannot be applied to your parameters.
    hint: you have to convert that String to a double,
    kind regards,
    Jos

  • Converting a Double To A String

    Is it possible to convert a double to a string. I need to retrieve a double value from an array and display it as a label in an applet.
    How do I convert the double value to a string so that I can use it in the applet as a label?
    Thanks

    try this.
    double mydbl = 0;
    String mystr = null;
    mysstr=mydbl+"".trim();
    Paulthis one is nice paul, but it is also possible to do it that way:
    double d = 0;
    String dStr = Double.toString(d);see also API for classes Boolean, Character, Integer, Byte, Float, Short
    all primitives can easyli be turned int for in which you can print them out.

  • Lost Digits of big Number - convert Double into Hex

    My Number is 24563383270390080
    if i debug the Variable it has got a value of 2.45633832703901e+016, so i lost a little bit of the value.
    if i bring ist into a sting, i can see the complete value "24563383270390080"
    i have to convert the number in to a Hex-Value, the Reuslt should be "$57444456503941" an can be written into a string.
    my problem is to bring the original value into a string of hex, because diadem round the last digits of my number
    i tryed several convertions, but the the probmel of lost digits is still there....
    maybe you´ve got an idea
    dim Number, NumberString, HexTest1, HexTest2, HexTarget
    Number = 24563383270390080  '17 Digits
    HexTarget = "$57444456503941"
    NumberString = Str(Number, "d")
    HexTest1  = Str((Data.Root.ChannelGroups("Neu").Channels("Vin_Data").Values(1)), "$")
    HexTest2  = Str(Val(Number), "$")
    '---> Result
    ''--> Number       = 2.45633832703901e+016
    '--> NumberString = "24563383270390080"
    '--> HexTarget  = "$57444456503941"  
    '--> HextTest1  =  $57444456503940  !!!!! Last Postion !!!!
    '--> HextTest2  =  $57444456503940

    You are a little bit out of luck with your example because
    dim number : Number = 24563383270390080 '17 Digits
    dim txt
    txt = txt & Str(Number, "d") & " ref: 24563383270390080" & VBCRLF
    txt = txt & Str(Number, "$") & " ref: $57444456503940" & VBCRLF
    MsgBox txt
     0 at the end is correct. (At least the MS calculator says so.) But this is by incident because of the number you picked.
    VBS only supports 64 bit double values. 64 bit doubles have a mantissa of 52 bits.
    24563383270390080
    becomes
    1010111010001000100010001010110010100000011100101000000
    which has 55 bit in use. Because your last bits aren't in use the number you picked can be represented by a double without loosing precission.
    24563383270390081
    would show the behavior you described because it is using 55bit range. The 1 is just cut when converted to double.
    But I have no solution for this because it will not work with VBS.

  • Converting a Labview time into a string with Measurement Studio C++

    In my Measurement Studio-based C++ application, I'll be sent a Labview
    time in the format of a double, which I believe is seconds since 1904.
    Does Measurement Studio for Visual C++ contain a function that will
    convert that time value into a string format? I'd like to end up with
    something like "hh:mm:ss:msec". I'm basically looking for the
    equivalent of the Labview vi, "Format Time/Date String". If Measurement
    Studio doesn't provide this, is there some other (hopefully simple) way
    to do this?
    I can request that the Labview application send me time in a string
    format as well as a double; this will require several changes to the
    Labview application sending the timestamp, but if that is a simpler
    solution that's the option we'll take.
    Thanks in advance,
    Adam

    Measurement Studio does not have a function for this, but you can do
    this yourself by first converting from LV epoch (1/1/1904) to Unix
    epoch(1/1/1970) and then using c runtime time functions
    UNIXEpochOffset is the difference between the 2 epochs at GMT. To
    convert to a UNIX system clock value, just subtract the sum of this
    number and your time zone offset in seconds
    lvTime is the value returned by LV timestamp
    #define  UNIXEpochOffset 2082844800
    int _tmain(int argc, _TCHAR* argv[])
        __int64 lvTime = 3214396284; //10:48:13.173 AM 11/9/2005
        //GMT offset for Central Time is -6 (3600 seconds). You will need to account for daylight savings time.
        int offset = -3600;
        time_t unixTime = lvTime - UNIXEpochOffset - offset;  
        struct tm *newtime = localtime(&unixTime);
        printf(asctime( newtime )); //prints out the time in a string format.
        return 0;
    Bilal Durrani
    NI

  • Putting a double into a label?

    I'm having trouble with this:
    finalPrice = (weightEntry * .89);
    //strFinalPrice = Double.(finalPrice);
    whatToDo.setText(finalPrice);whatToDo is declared as a label
    finalPrice is declared as a double
    The error im getting is that setText cant be applied to a double.

    When I have
    strFinalPrice = finalPrice;
    I get incompatible types, how can I format it into a string?

  • How to catch exception into a String variable ?

    I have a code
    catch(Exception e)
                e.printStackTrace();
                logger.error("\n Exception in method Process"+e.getMessage());
            }when i open log i find
    Exception in method Process null.
    But i get a long error message in the server console !! I think thats coming from e.printStackTrace().
    can i get the error message from e.printStackTrace() into a String variable ?
    I want the first line of that big stacktrace in a String variable.
    How ?

    A trick is to issue e.printStackTrace() against a memory-based output object.
    void      printStackTrace(PrintStream s)
             // Prints this throwable and its backtrace to the specified print stream.
    void      printStackTrace(PrintWriter s)
    //          Prints this throwable and its backtrace to the specified print writer.Edited by: BIJ001 on Oct 5, 2007 8:54 AM

  • Need to convert a long into a string, please

    hi there
    i need to convert a long into a string. can i just cast it like this:
    (String)longNumber = some function that returns a long;

    Why not just use Long.toString()? If you start with a long value, you can create a Long object and get it's value as a String.

  • CAN I TURN MY MACBOOK PRO INTO A MONITOR?

    Help I want to turn my Macbook Pro into a monitor for my Playstation 2 so that way I can record on my screen using quicktime. please help I used a vga adapter from apple a AV to vga converter, and is their any way for me to use an iphone on a mac to play ios games while recording?

    I don't think you can without some sort of capture card (very expensive, and because most MacBook Pros don't have a card, you need to use the FW800).  MBP's Thunderbolt port only sends video signals out, you can't attach an HDMI to Mini DisplayPort cable from your camera to the MBP and expect to show video.
    You could try a utility like Sofortbild. 

  • I am trying to transfer my photos from old mac to new mac.  I copied the iPhoto library to an external hard drive, then imported it to the new iPhoto.  It turned my 2000 photos into 12,000!!  What happened?

    And how do I turn off FACES? 

    I copied the iPhoto library to an external hard drive, then imported it to the new iPhoto.  It turned my 2000 photos into 12,000!!
    According to you youo did not do what I instructed - you said you imported the old library into th enew library which can easily take a 2000 photo library and turn it into 12,000 including two ro three versions of each photo pus all the face thumbnails
    The correct procedure has NO importing involved
    drag the iPhoto library intact as a single entity from the old Mac to the pictures folder of the new Mac - launch iPhoto on the new mac
    That is it
    LN

Maybe you are looking for

  • How about use partial key to loop at a hashed table?

    Such as I want to loop a Internal table of BSID according to BKPF. data itab_bsid type hashed table of BSID with unique key bukrs belnr gjahr buzid. Loop at itab_bsid where bukrs = wa_bkpf-bukrs                           and    belnr  = wa_bkpf-belnr

  • Data buffer(st04) is lower and lower

    recently, i find such an  information in our sap system using ST04. Following is message: Data buffer Size              kb      3,194,880 Quality            %           89.4 the quality value is lower an lower. why? what should i do? please help me !

  • How do I modify the test of an enumeration programmatically?

    Hi everyone, I have an application with 8 scopes on it and the data displayed on the scope is selected by a drop down menu which is an enum control that is a typedef.  Since this application interfaces with different hardware, I need to be able to ch

  • Photoshop elements 12 will not validate in installation

    Photoshop elements 12 will not validate in installation

  • [solved-ish]hardware / 3D acceleration problems with Nvidia drivers

    Hi, I am getting really slow response with 3d applications. I just tried glxgears and am not getting any more than 3 fps!!!!!!!!!!!!!!! Any ideas would be appreciated. xorg.conf # nvidia-settings: X configuration file generated by nvidia-settings # n