Menu
Menu
DaniWeb
Log In
Sign Up
Read
Contribute
Meet
Search
Search
About 1,000 results for
valueof
- Page 1
Java- Payroll program help with String.valueOf()
Programming
Software Development
13 Years Ago
by CB8379
… System.out.println("Product name: ", + String.
valueOf
(ProdArray[i].getProductName())); System.out.println("Product Category: &….out.println("Product re-stocking fee: " +String.
valueOf
(ProdArray[i].getFee())); System.out.println(); //print blank line }…
Re: Java- Payroll program help with String.valueOf()
Programming
Software Development
13 Years Ago
by CB8379
… be output, but it does not seem that the String.
valueOf
() is working according to what I had planned. Did I…
Re: Java- Payroll program help with String.valueOf()
Programming
Software Development
4 Years Ago
by Kandapatrick19
….getText()); pst.setString(2, txtpass.getText()); pst.setString(3, String.
valueof
(jComboBox1.getSelectedItem())); // this line i have error message no method…
Re: String methods - valueOf
Programming
Software Development
15 Years Ago
by AbhikGhosh
…if(fileext.equalsIgnoreCase("txt")) { output = String.
valueOf
(true); System.out.print(output + " ");… System.out.println(description); } else { output = String.
valueOf
(false); System.out.print(output + " "); } } catch…
Re: String methods - valueOf
Programming
Software Development
15 Years Ago
by thekashyap
[CODE] //may be you didn't notice that
valueOf
is a static method. String suffix = String.
valueOf
(firstin.endsWith(actual)); //OR give you have only 2 values.. String suffix = (firstin.endsWith(actual))? "true" : "false" ; [/CODE]
Re: String methods - valueOf
Programming
Software Development
15 Years Ago
by anevins
…] //may be you didn't notice that
valueOf
is a static method. String suffix = String.
valueOf
(firstin.endsWith(actual)); //OR give you…
Re: String methods - valueOf
Programming
Software Development
15 Years Ago
by KirkPatrick
In your post it says you need to use
valueOf
, however, if you aren't absolutely stuck on using that, … it looks like you might have a requirement of using
valueOf
Re: Is the valueOf method called during autoboxing ?
Programming
Software Development
14 Years Ago
by ~s.o.s~
[quote]Is it true that during autoboxing, the type.
valueOf
() method is called (which creates a new object only if … it doesn't explicitly say that it is the "
valueOf
" method which would be invoked.
String methods - valueOf
Programming
Software Development
15 Years Ago
by anevins
I need to use the
valueOf
method to return a string representation of a boolean arguement …
using Double.valueOf(args[0]).doubleValue()
Programming
Software Development
14 Years Ago
by migicikinyanjui
… { public static void main (String[] args) { try { double price = Double.
valueOf
(args[0]).doubleValue(); double salestax = price * 0.0825; System.out…
Re: using Double.valueOf(args[0]).doubleValue()
Programming
Software Development
14 Years Ago
by stephen84s
Ehhh... We knows you have problem, but [I]What is the problem[/I] doc ? [code=java] Double.
valueOf
(args[0]).doubleValue() [/code] Extracts a [B]double[/B] value from the given [B]String[/B] object (args[0]). Same can be achieved a bit more easily by just [icode]Double.parseDouble(args[0])[/icode]
Is the valueOf method called during autoboxing ?
Programming
Software Development
14 Years Ago
by daudiam
Is it true that during autoboxing, the type.
valueOf
() method is called (which creates a new object only if another with the same primitive constant is not in the intern list. This applies to cases where interning is allowed. Otherwise, it creates a new object using new() ). Is this right ?
Re: Java- Payroll program help with String.valueOf()
Programming
Software Development
13 Years Ago
by Ezzaral
Take another look at the calls in those error messages. Does your ProdArray have a getFee() method?
Re: Java- Payroll program help with String.valueOf()
Programming
Software Development
13 Years Ago
by CB8379
It does have a getFee method .. (I think).. it is in the subclass (line 189). Or am I incorrect?
Re: Java- Payroll program help with String.valueOf()
Programming
Software Development
13 Years Ago
by Ezzaral
ProdArray is just an array.
Re: Java- Payroll program help with String.valueOf()
Programming
Software Development
13 Years Ago
by CB8379
the ProdArray[] is meant to hold objects (I actually had 20 points knocked off on Sunday because I was not using objects in my code, so I tried to update it). I still have not had one successful build since my first project.
Re: Java- Payroll program help with String.valueOf()
Programming
Software Development
13 Years Ago
by Ezzaral
There is a difference between calling a method on an array and calling a method on an [I]element[/I] of the array.
Re: Java- Payroll program help with String.valueOf()
Programming
Software Development
13 Years Ago
by CB8379
All right, I think that I am officially confused now. I had gone back to re-read our text. From what I can tell, either the elements can be passed to a method for modification or the array value could be passed to the method to modify. With the program I am trying to build, the array element needs to be passed to the method because each element …
Re: Java- Payroll program help with String.valueOf()
Programming
Software Development
13 Years Ago
by Ezzaral
The important difference here is that ProdArray is an array reference. ProdArray[0] is an element of that array. It is those elements that you wish to call methods on. Look at line 89 in the code you posted above. See the difference in syntax?
Re: Java- Payroll program help with String.valueOf()
Programming
Software Development
13 Years Ago
by CB8379
ok.. I think I know what you are saying. So instead of having getProductNumber(), I should have getProductNumber[i].. Or am I still completely wrong?
Re: Java- Payroll program help with String.valueOf()
Programming
Software Development
13 Years Ago
by Ezzaral
You specify the index of the element on the array itself. As I said, look at lines 89,90,91... in your code above. On those lines, you are calling methods on a particular element in the ProdArray array. ProdArray[0] is the first element in ProdArray. It is an object of type 'Product4'. ProdArray[1] is the second element in ProdArray.
Re: Java- Payroll program help with String.valueOf()
Programming
Software Development
13 Years Ago
by CB8379
I tried to change the method calls for output to getProductNumber(i); (i is for the count in the array as it passes though each item element) and now I am receiving the error: cannot be applied to given types.
Re: Java- Payroll program help with String.valueOf()
Programming
Software Development
13 Years Ago
by Ezzaral
Ok, third time: look at line 89. Do you see anything that looks like getProductNumber(i)?
Re: Java- Payroll program help with String.valueOf()
Programming
Software Development
13 Years Ago
by CB8379
all right- on line 89 I have ProdArray[i].getProductNumber(). The ProdArray[i] is meant to retrieve the element stored in the given loop for [i], weather it be element [0] through [4] and for each pass through the array of elements, display what is in the array. You asked if I see anything that looks like getProductNumber(i) and that would be what …
Re: Java- Payroll program help with String.valueOf()
Programming
Software Development
13 Years Ago
by Ezzaral
You have already gotten the object. It is ProdArray[i]. You call methods on it just the same as you would any Product4 object. You don't specify any indexes in the method call parenthesis.
Re: String methods - valueOf
Programming
Software Development
15 Years Ago
by JamesCherrill
I'm curious. Why return a String rather than the boolean?
Re: String methods - valueOf
Programming
Software Development
15 Years Ago
by JamesCherrill
If all you want to do is to print the boolean there's no need to convert to String - print does that for you. You can just use System.out.print("My boolean is " + myBooleanVariable);
Re: String methods - valueOf
Programming
Software Development
15 Years Ago
by anevins
[QUOTE=JamesCherrill;1110122]I'm curious. Why return a String rather than the boolean?[/QUOTE] Sorry about not replyin earlier, the requirement is to return a specific sentence, rather than just 'true' or 'false'
Re: String methods - valueOf
Programming
Software Development
15 Years Ago
by JamesCherrill
If you need a sentence, I'd go with String sentence = (myBooleanVar) ? "Sentence 1": "Sentence 2"; (like in post #2)
Re: String methods - valueOf
Programming
Software Development
15 Years Ago
by thekashyap
[QUOTE=anevins;1110092]On your 4th line of code, that gives my IDE an error of incompatible types, required : boolean, found : java.lang.String[/QUOTE] First: It's this OR that. Use the one that works. Second: I tested the code before posting. Checked again, it compiles fine with 1.5 & 1.6. Unless you changed the type of "suffix"…
1
2
3
17
Next
Last
Search
Search
Forums
Forum Index
Hardware/Software
Recommended Topics
Programming
Recommended Topics
Digital Media
Recommended Topics
Community Center
Recommended Topics
Latest Content
Newest Topics
Latest Topics
Latest Posts
Latest Comments
Top Tags
Topics Feed
Social
Top Members
Meet People
Community Functions
DaniWeb Premium
Newsletter Archive
Markdown Syntax
Community Rules
Developer APIs
Connect API
Forum API Docs
Tools
SEO Backlink Checker
Legal
Terms of Service
Privacy Policy
FAQ
About Us
Advertise
Contact Us
© 2025 DaniWeb® LLC