How to roundup String array values
Hello friends,
I have some problem in my jsp page, if i give the qty value 12345.9876 like this i have problem if i will give like this 12345.99
it work so i want to roundup the values how to round up the string[] saQty=null;
the saQty i want to round up how it's possible
pls any one can help me.................
Hello friends,
I have some problem in my jsp page, if i givethe
he qty value 12345.9876 like this i have problemif
i
will give like this 12345.99
it work so i want to roundup the values how toround
up the string[] saQty=null;
the saQty i want to round up how it's possible
pls any one can help me.................i have do today itself pls any one help me....You waited for two minutes?
Just convert the strings to e.g. BigDecimal, then
round them, and convert back to string.
Kaji have tried with this code but i got error that bigdecimal we cannot pass String array so that i asked u.......
BigDecimal gridQty = null;
gridQty = new BigDecimal(arrQty);
gridQty = gridQty.setScale(2,BigDecimal.ROUND_HALF_UP);
arrQty = gridQty.toString();
System.out.println("Ramesh gross :"+gridQty);
Similar Messages
-
Can any body tell me How to store string array in a array
Can any body tell me How to store string array in a array
YesNot quite sure what question you're answering but here's how to copy an array.// given a String[] strArr
// pre Java 6
String[] newStrArr = new String[strArr.length];
System.arrayCopy(strArr, 0, newStrArr, 0, strArr.length);
// post Java 6
String[] newStrArr = Arrays.copyOf(strArr, strArr.length);Edit:
Or in fact use clone() as mark pointed out.
Message was edited by:
dwg -
How to Pass String array from Java to PL/SQL and this use in CURSOR
hi,
I cant understand how to pass Array String as Input Parameter to the Procedure and this array use in Cursor for where condition like where SYMPTOM in( ** Array String **).
This array containing like (SYMPTOM ) to be returned from the java to the
pl/sql (I am not querying the database to retrieve the information).
I cannot find an example on this. I will give the PL/SQL block
create or replace procedure DISEASE_DTL<*** String Array ***> as
v_SYMPTOM number(5);
CURSOR C1 is
select distinct a.DISEASE_NAME from SYMPTOM_DISEASE_RD a
where ltrim(rtrim(a.SYMPTOM)) in ('Fever','COUGH','Headache','Rash') ------- ***** Here use this array element(like n1,n2,n3,n4,n5..) ******
group by a.DISEASE_NAME having count(a.DISEASE_NAME) > 3 ----------- ***** 3 is no of array element - 1 (i.e( n - 1))*****
order by a.DISEASE_NAME ;
begin
for C1rec IN C1 loop
select count(distinct(A.SYMPTOM)) into v_SYMPTOM from SYMPTOM_DISEASE_RD a where A.DISEASE_NAME = C1rec.DISEASE_NAME;
insert into TEMP_DISEASE_DTLS_SYMPTOM_RD
values (SL_ID_SEQ.nextval,
C1rec.DISEASE_NAME,
(4/v_SYMPTOM), --------**** 4 is no of array element (n)************
(1-(4/v_SYMPTOM)));
end loop;
commit;
end DISEASE_DTL;
Please give the proper solution and step ..
Thanking you,
AsishI've haven't properly read through your code but here's an artificial example based on a sql collection of object types - you don't need that, you just need a type table of varchar2 rather than a type table of oracle object type:
http://orastory.wordpress.com/2007/05/01/upscaling-your-jdbc-app/ -
How to Display string array in jsp page using netui-data:repeater tag ??
hi,
I am trying to display a string array in a table using the netui-data:repeater tag.
I have to use a page flow controller Array(1 Dimensional) to be displayed in the jsp.
Can any one tell me how to print the array in a table of 3rows & 5 columns.
Here is the code on which I am crrently working on.
<netui-data:repeater dataSource="{pageFlow.strWorkObject_Array}">
<netui-data:repeaterHeader>
<table cellpadding="4" border="1" class="tablebody">
</netui-data:repeaterHeader>
<netui-data:repeaterItem>
<tr>
<td><netui:label value="{container.item}" >
</netui:label></td>
<td><netui:label value="{container.item}">
</netui:label></td>
<td><netui:label value="{container.item}">
</netui:label></td>
</tr>
</netui-data:repeaterItem>
<netui-data:repeaterFooter>
</table>
</netui-data:repeaterFooter>
</netui-data:repeater>weblogic.developer.interest.workshop
Mansoor Naseem wrote:
I would like to know where the pageflow newsgroup is.
These are all the groups in weblogic.developer.interest:
weblogic.developer.interest.60beta.* (5 groups) weblogic.developer.interest.management
weblogic.developer.interest.61beta.* (2 groups) weblogic.developer.interest.misc
weblogic.developer.interest.clustering.* (1 group) weblogic.developer.interest.performance
weblogic.developer.interest.commerce weblogic.developer.interest.personalization
weblogic.developer.interest.ejb.* (3 groups) weblogic.developer.interest.portal
weblogic.developer.interest.environment weblogic.developer.interest.rmi-iiop
weblogic.developer.interest.jdbc weblogic.developer.interest.security
weblogic.developer.interest.jms weblogic.developer.interest.servlet
weblogic.developer.interest.jndi weblogic.developer.interest.tools
weblogic.developer.interest.jsp weblogic.developer.interest.weblogicenterprise
MN -
How do I display array values in a text field?
Hi there-
I have a small Flash movie I'm trying to complete, it's my
first go around with Flash 8 so I appreciate your patience:
I built an array with some actionscript which seems to work
fine (I can trace it and all is well in the trace window). Now I'm
simply trying to display it to my Flash movie screen and I've built
a dynamic text window which is working, except that I only ever get
the last array element to appear in the dynamic text window. I've
traced the code and see all of my array values, but when I use
"myResults_txt.text=picker_array;" I only see the last position's
value in my array. I tried playing with the "multiline" attribute
for the text field, it didn't seem to make any difference.
I'm sure it's probably something silly that I've missed, but
how do you display an array, with all of it's values to a dynamic
text field (I even tried using the textArea component but ran into
the same problem).
Thanks in advance for any help-
richThanks for your input. I tried just about everything but
ended up re-writing the contents of the array to a var and looping
through the var. Not my first choice but it got me to done.
Thanks again,
Rich -
How to check string array elements with a string with in one forEach tag ?
Hi All,
I am new to JSTL and EL. I need to change the following Java code into JSTL and EL.. I struggled to change this code into JSTL.
How can i change the if loop which tests the string array element with one bean property ?
-------------------------------------------------------------------------------------------------------------for(int j=0 ; j < iSelectedCount; j++)
if(strSelectedRoleId[j].equals(lineRole.getRoleID()))
isAvailable = true;
Please help me on this.
It is very urgent......
Thank you for ur help,
Natrajimport java.util.Calendar;
Calendar rightNow = Calendar.getInstance(); // gets the current date and time to millisec
Calendar earlyTime = Calendar.getInstance().set(Calendar.HOUR_OF_DAY, 6).set(Calendar.MINUTE, 30);
Calendar lateTime = Calendar.getInstance().set(Calendar.HOUR_OF_DAY, 8).set(Calendar.MINUTE, 0);
if (rightNow.compareTo(earlyTime)> 0 && rightNow.compareTo(lateTime) < 0){
// do something
}Try this. -
How to convert String array into int.
void getSoldSms(Vector vecSoldSms)
String str[]=new String[vecSoldSms.size()];
String words[]=new String[str.length]; // String array
for(int i=0;i< vecSoldSms.size();i++)
str=(String)vecSoldSms.get(i);
} //End for
for(int i=0;i<str.length;i++)
words = str[i].split("\\|\\|");
System.out.println();
for(int j=0;j<1;j++)
int count[str.length]=Integer.parseInt(words[i]);
System.out.print(count[j]*advance_count);
} // end inner for loop
} //End for
} //End function getSoldSms
how do i convert words which is a string array into int type. i kno string can be converted into int using interger.parseint. but wat abt string arrays??? plz help me out with the above code.i did tht its still giving the same errorFor Heaven's sake, what about taking a second to try to understand the code you're copying first? If you really can't fix the error yourself, you have a more serious problem than just convertingStrings to ints.
And if you want { "1", "2", "3" } to be 123:
StringBuffer b = new StringBuffer();
for (int i = 0; i < array.length; i++) {
b.append(array);
int result = Integer.parseIn(b.toString()); -
How to retrieve string array using Session?
Hi, I am having some problem retrieving string arrays through session.
String personalData[] = new String[17];
personalData = (String [])session.getValue("PersonalData");
The coding above isn't working. Advise pls.. ThanksThe getValue() method is deprecated - you should probably be using getAttribute.
What about this code isn't working? Looks ok to me, as long as the "PersonalData" object in the session is a String[] it should work.
Cheers,
evnafets -
How to populate string array in table view.
Hi,
By using webservice i am able to get an array of strings but, I am unable to populate those values in the tableview.
Can any one please suggest me how to populate array of strings in table view with an example.
Thanks,
SRI.Search this forum. You will find plenty of threads on the same...
Raja -
How to get String assigned value
Hi,
As String is immutable and we know that the value of string is not changable.
eg: String abc= new String();
abc = "INDIA";
system.out.println("1st abc : "+abc);
abc=abc.toLowerCase();
system.out.println("2nd abc : "+abc);
As we know as string is immutable the value for the 2nd abc gives us india.As 2nd abc creates a new instance object stores in new memory location.
Then y string is called immutable.It means the value is getting changed.
Is their a way to retrive my original value or first assigned value for abc i.e INDIA.
Thanks
LeoSun.LeoSun wrote:
Then y string is called immutable.It means the value is getting changed.No, it is not changed, you just assign a new value to your variable 'abc'.
String abc = "INDIA";
+-----------+
abc -----+-> "INDIA" |
+-----------+
abc = abc.toLowerCase();
+-----------+
abc ---+ | "INDIA" |
| | |
+-+-> "india" |
+-----------+As you see, "INDIA" is not changed, a new String, "india" is created where your variable 'abc' points to.
Is their a way to retrive my original value or first assigned value for abc i.e INDIA.
...Once you change the value of 'abc' (and there exists no reference to it's old value), then no, it's not possible.
Why would you want that? -
How to map an array to fixed fields using Biztalk mapper
I need to remap an array of objects like this:
<Root>
<ListOfObjs>
<Obj>
<Attr1>0000</Attr1>
<Attr2>Hello!</Attr2>
</Obj>
<Obj>
<Attr1>1111</Attr1>
<Attr2>Hello1!</Attr2>
</Obj>
</ListOfObjs>
</Root>
in an output like this:
<Root>
<Obj1_Attr1>0000</Obj1_Attr1>
<Obj1_Attr2>Hello!</Obj1_Attr2>
<Obj2_Attr1>1111</Obj2_Attr1>
<Obj2_Attr2>Hello1!</Obj2_Attr2>
</Root>
So in my XSD schema I have something like this:
Schema Input
<xs:element name="Root">
<xs:complexType>
<xs:sequence>
<xs:element name="ListOfObjs">
<xs:complexType>
<xs:sequence>
<xs:element name="Obj">
<xs:complexType>
<xs:sequence>
<xs:element name="Attr1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:maxLength value="50"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="Attr2">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:maxLength value="50"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
Schema output
<xs:element name="Root">
<xs:complexType>
<xs:sequence>
<xs:element name="Obj1_Attr1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:maxLength value="50"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="Obj1_Attr2">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:maxLength value="50"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="Obj2_Attr1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:maxLength value="50"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="Obj2_Attr2">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:maxLength value="50"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
In addiction I have to evaluate every single value because when I found some conditions (like if value=0000 output should be NULL).
What would be the best way to do it? I'm thinking to develop a custom functoid but I'm not sure it would be the best way, probably it could be done even using XSLT inline transforms, can you point me in the best direction?
Thank youHi,
You cannot directly map an array output to any single field in BizTalk mapper.
Couple of options :
1) create
the Xslt or inline C# code
Refer:
http://seroter.wordpress.com/2008/10/07/splitting-delimited-values-in-biztalk-maps/
2) Shankycheil has
provided a solution to similar requirement in the below link, u can also refer that.
https://social.msdn.microsoft.com/Forums/en-US/55ec472d-4f34-4057-b1c6-0e50740f0f6e/how-to-itterate-string-array-values-in-biztalk-mapper?forum=biztalkgeneral
Rachit
Thank you, I already seen both posts, but I'm not sure they are what I need or I can't understand well how to use them.
Speaking about the first solution, as I told before, in the example I should have an array already formed and delimited by a char (something like "obj1attr1-obj1attr2-ob2attr1-obj2attr2". In this situation probably this example could be a good
point to start from, but how to transform my complex input object in a similar formatted string?
About the second I don't understand well what is the working solution that they have adopted. Is the 4 steps solution suggested by Shankycheil? If yes, how can I loop between all array elements and extract all their values? -
Searching two dimensional string arrays
Hello, I'm very new to Java. I would like some advice on the code below. What I'm trying to do is: I want the user to enter a 9 digit number which is already stored in an two dimensional array. The array is to be searched and the 9 digit number and corresponding name is to be printed and stored for future reference. Something is wrong with my array checking. If I enter the nine digit number, the program errors and asks me again for the number. If I enter 0-4, I receive an output. I just don't know how to compare string array values. Could someone please help me with this?
import java.io.*;
import java.util.*;
public class SocialSn2
public static void main(String args[]) throws Exception
boolean validSSAN = false;
Ssn(validSSAN);
if (validSSAN)
//Ssn(false);//write the code here to continue processing
}//end main
public static void Ssn(boolean Validated)
String[][] employees =
{{"333333333", "Jeff"},
{"222222222", "Keith"},
{"444444444", "Sally"},
{"555555555", "Kaylen"},
{"111111111", "Sheriden"} };
boolean found = false;
while (!found)
System.out.println("Enter the employee's Social Security number.");
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
try
String line = in.readLine();
int input = Integer.parseInt(line); //added
found = false;
for(int j = 0; j < 5; j++)
if(input >= 0 && input <= employees.length)
//if(employees[j][0].equals(input))
//System.out.println(employees[input][0] + employees[input][1]);
found = true;
System.out.println(employees[input][0] + " " + employees[input][1]);
catch (Exception exc)
System.out.println("error");
found = false;
Validated = found;
}//end Ssn
}//end classThere seems to be some problem with your loop for checking those values
if you had used System.err.println() in your catch block you would see that you were getting an ArrayIndexOutOfBoundsException
The following works for me.
import java.io.*;
import java.util.*;
public class SocialSn2
public static void main(String args[]) throws Exception
boolean validSSAN = false;
Ssn(validSSAN);
if (validSSAN)
//Ssn(false);//write the code here to continue processing
}//end main
public static void Ssn(boolean Validated)
String[][] employees =
{{"333333333", "Jeff"},
{"222222222", "Keith"},
{"444444444", "Sally"},
{"555555555", "Kaylen"},
{"111111111", "Sheriden"} };
boolean found = false;
System.out.println(employees.length);
System.out.println(employees[0].length);
while (!found)
System.out.println("Enter the employee's Social Security number.");
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
try
String line = in.readLine();
//int input = Integer.parseInt(line); //added
found = false;
for (int i=0; i< employees.length;i++)
if(employees[0].equals(line))
System.out.println(employees[i][0]+" "+employees[i][1]);
found = true;
catch (Exception exc)
System.err.println(exc);
found = false;
Validated = found;
}//end Ssn
}//end class -
How can I return Array of String to client
Hi all,
I am a new learner about web services, can any one tell me how to return of get a String of array from OMElement ?
I have two server side method want to create, first method receive an array of string and second method return an an array of String. How should I implement it.
public org.apache.axiom.om.OMElement OneWayRequest() {
//How Please help me
public void LoadDummyNumberForInventory(
org.apache.axiom.om.OMElement loadDummyNumberForInventory0) {
//How get the String array ?
}Hi all,
I am a new learner about web services, can any one tell me how to return of get a String of array from OMElement ?
I have two server side method want to create, first method receive an array of string and second method return an an array of String. How should I implement it.
public org.apache.axiom.om.OMElement OneWayRequest() {
//How Please help me
public void LoadDummyNumberForInventory(
org.apache.axiom.om.OMElement loadDummyNumberForInventory0) {
//How get the String array ?
} -
Newbie trying to sort 2D string array
Dear all,
After read some book chapters, web sites including this, I still don't get the point.
If I have a file like,
1 aaa 213 0.9
3 cbb 514 0.1
2 abc 219 1.3
9 bbc 417 10.4
8 dee 887 2.1
9 bba 111 7.1
and I load into memory as a String[][]
here comes the problem, I sort by column 1 (aaa,...,bba) using an adaptation of the Quicksort algorithm for 2D arrays
* Sort for a 2D String array
* @param a an String 2D array
* @param column column to be sort
public static void sort(String[][] a, int column) throws Exception {
QuickSort(a, 0, a.length - 1, column);
/** Sort elements using QuickSort algorithm
static void QuickSort(String[][] a, int lo0, int hi0, int column) throws Exception {
int lo = lo0;
int hi = hi0;
int mid;
String mitad;
if ( hi0 > lo0) {
/* Arbitrarily establishing partition element as the midpoint of
* the array.
mid = ( lo0 + hi0 ) / 2 ;
mitad = a[mid][column];
// loop through the array until indices cross
while( lo <= hi ) {
/* find the first element that is greater than or equal to
* the partition element starting from the left Index.
while( ( lo < hi0 ) && ( a[lo][column].compareTo(mitad)<0))
++lo;
/* find an element that is smaller than or equal to
* the partition element starting from the right Index.
while( ( hi > lo0 ) && ( a[hi][column].compareTo(mitad)>0))
--hi;
// if the indexes have not crossed, swap
if( lo <= hi )
swap(a, lo, hi);
++lo;
--hi;
/* If the right index has not reached the left side of array
* must now sort the left partition.
if( lo0 < hi )
QuickSort( a, lo0, hi, column );
/* If the left index has not reached the right side of array
* must now sort the right partition.
if( lo < hi0 )
QuickSort( a, lo, hi0, column );
* swap 2D String column
private static void swap(String[][] array, int k1, int k2){
String[] temp = array[k1];
array[k1] = array[k2];
array[k2] = temp;
----- end of the code --------
if I call this from the main module like this
import MyUtil.*;
public class kaka
public static void main(String[] args) throws Exception
String[][]a = MyUtil.fileToArray("array.txt");
MyMatrix.printf(a);
System.out.println("");
MyMatrix.sort(a,1);
MyMatrix.printf(a);
System.out.println("");
MyMatrix.sort(a,3);
MyMatrix.printf(a);
for the first sorting I get
1 aaa 213 0.9
2 abc 219 1.3
9 bba 111 7.1
9 bbc 417 10.4
3 cbb 514 0.1
8 dee 887 2.1
(lexicographic)
but for the second one (column 3) I get
3 cbb 514 0.1
1 aaa 213 0.9
2 abc 219 1.3
9 bbc 417 10.4
8 dee 887 2.1
9 bba 111 7.1
this is not the order I want to apply to this sorting, I would like to create my own one. but or I can't or I don't know how to use a comparator on this case.
I don't know if I am rediscovering the wheel with my (Sort String[][], but I think that has be an easy way to sort arrays of arrays better than this one.
I've been trying to understand the Question of the week 106 (http://developer.java.sun.com/developer/qow/archive/106/) that sounds similar, and perfect for my case. But I don't know how to pass my arrays values to the class Fred().
Any help will be deeply appreciated
Thanks for your help and your attention
Pedropublic class StringArrayComparator implements Comparator {
int sortColumn = 0;
public int setSortColumn(c) { sortColumn = c; }
public int compareTo(Object o1, Object o2) {
if (o1 == null && o2 == null)
return 0;
if (o1 == null)
return -1;
if (o2 == null)
return 1;
String[] s1 = (String[])o1;
String[] s2 = (String[])o2;
// I assume the elements at position sortColumn is
// not null nor out of bounds.
return s1[sortColumn].compareTo(s2[sortColumn]);
// Then you can use this to sort the 2D array:
Comparator comparator = new StringArrayComparator();
comparator.setSortColumn(0); // sort by first column
String[][] array = ...
Arrays.sort(array, comparator);I haven't tested the code, so there might be some compiler errors, or an error in the logic. -
How to convert string containing comma seperated values to an array
my requirement is i have to first convert an comma seperated string to an array
after that i have to pass the array values to a for loop
eg:i have a string str=(456,457,487,465,478)
These values i have to put in an array.
i then i have to pass the array values to a for loopWe understand your ¿homeworks? We are helping you, but it seems like you want us to do it.
Try it yourself with some of the instructions.
Anyway if there aren´t homeworks, use dinamyc sql:
declare
varray := '(45,65,12,4)';
begin
execute immediate 'update table set ss=''uu'' where id in ' || varray;
end;
Maybe you are looking for
-
After, trying Mozilla 4 beta and then having to go back to a previous vs of Mozilla 3.6.11 my MS OLE DB Provider for SQL 2005 Server has this error message '80040E57' I am using Windows 7 which was pre-installed on my new computer. I do not know how
-
some how I moved the screen over and lost the left side It will not let me grab it and drag it back it is not from the arrow in the top right corner and hitting esc does not fix it. HELP.
-
Running Final Cut Studio 2 with only 512 MB
I have 2 older mac mini's laying around and I would like to put them to work. I was thinking that they could log and capture and only do that. If they are logging, then the other computers are freed up to edit. The problem that I am having is that th
-
Formula for Days of Supply, 1st RDS, 2nd RDS in MD06
Dear Guru, Can you share formulas for Stock DS, 1st RDS and 2nd RDS in MD06?
-
Pls Advice me on Exception code.
Dear All, Need to know what is making the exception code 20 show up in the two open purchase orders. The exception code is causing MRP to create requisition to order additional stock when we are already above MAX. TIA Kogi