To get a real length of an array
if there is an array not full,how do i calcuate how many elements in an array are??
for example:
ARRAY A={"A","B","NULL","NULL"};
HOW TO FIND THE LENGTH IS "TWO"
THANKS IN ADVANCE
String[] a = {"a", "b", "null", "null"};
has length four as well as having four filled Strings in it.
however..
String[] a = new String[4];
a[0] = "a";
a[1] = "b";
and you want to find out that there are two in it?
then count like r.klemme said.
int count =0;
for (int i=0;i<a.length;i++) {
if (a[i] != null) count++;
System.out.println("array " + a + " has length=" + a.length + " with " + count + "units in it");
Similar Messages
-
How to get the real length of a 3D room
Hi, I want to built a 3d room. When I import a obj file, the vector3f length does not equal to the real length(much longer than the real one), I know there must be relation between them, but how I can get the relation?
for example:
T3Droom.setTranslation(new Vector3f(0.7f,1f,0.5f));
How many metres the 0.7f equals to?
thanks a lotjavax.mail.Address[] addrs= m.getFrom();
Address a = addrs[0];
if (a instanceof InternetAddress &&
((pers = ((InternetAddress)a).getPersonal()) != null)) {
String addr = ((InternetAddress)a).getPersonal();
} else
addr = a.toString();
this 'getPersonal()' is the thing you need. -
Länge eines Array (length of an array)
Hallo,
gibt es ähnlich wie bei Kanälen - chnlength - eine Möglichkeit die Länge von Arrays abzufragen?
Is there any possibility to get the length of an array like chnlength?
GrußArrays in vbs are a little tricky.
Thats mainly because
dim arr()
does not create an empty array but an unitialized one. So calling Ubound(arr) will raise an error.
It will also fail to loop using "for each".
So I would suggest to never use "()" to define an array but
dim arr : arr = Array()
MsgBox "length=" & ubound(arr) + 1
dim arrElem
for each arrElem in arr
' here we can do something
Next
Array() will create an initialized Array of length 0. UBound will give -1 as return value.
Usng this returing an array from a funtion works quiet well without having to check for exceptions if array is empty.
Option Explicit
Function GetElems()
GetElems = Array()
' do some stuff
end function
dim elems : elems = GetElems
dim elem
for each elem in elems
' here we can do something
Next
If you want to dynamically grow an array you can use redim preserve.
Option Explicit
dim arr : arr = Array()
redim preserve arr(Ubound(arr) + 1)
arr(UBound(arr)) = "Appended text"
MsgBox "length=" & ubound(arr) + 1 & VBCRLF & arr(0) -
How can I get the real column of an alias in a view using system catalogs?
Given a view with columns that use aliases, I would like to get the real column name for the view column with the alias.
For example,
CREATE VIEW myView AS
SELECT name as col_1, price as col_2, price + 1000 as col_3
FROM myTable
I want to get that 'col_1' is actually the 'name' column and 'col_2' is the 'price' column by querying the system catalogs of SQL Server. It would be great to know whether I can resolve what 'col_3' is in the
example as well (i.e., when an alias is an expression, not just a column).
Thanks in advance.Or you can use the System function
sys.dm_exec_describe_first_result_set, example
CREATE TABLE myTable
(name varchar(30), price money);
GO
CREATE VIEW myView AS
SELECT name as col_1, price as col_2, price + 1000 as col_3
FROM myTable;
GO
SELECT name, source_table, source_column
FROM sys.dm_exec_describe_first_result_set(N'SELECT * FROM myView', NULL, 1) AS FRS
=>
Olaf Helper
[ Blog] [ Xing] [ MVP] -
For some reason the system is telling me my birth date is wrong when it's not and it won't let me proceed to reset my password. Can someone tell me how to get a "real" person from tech on line?
contact itunes support
-
How to get the real name of a user from WFSYST-AGENT
Hi,
I am retrieving the WFSYST-AGENT value (which correspond to the US<user_id> of the agent responsible of a task) in a container variable in my workflow.
I would like to get the real name of the user represented by WFSYST-AGENT. How should I do that ?
Thanks in advance for your help.
ThibaultHi,
Take the user name and write a select for database table USER_ADDR fetching fields NAME_FIRST and NAME_LAST by passing BNAME = username.
Regards,
Jayesh -
How to get the real path of the xml file
I have a java application
following is the package structure
com>>gts>>xml
having file---------> MyXML.xml
com>>gts>>java
having java program to read the file
Problem is if I use File file = new File("..\\xml\\MyXML.xml");
java.io.FileNotFoundException: E:\LEARNING_WORK_SPACE\JavaXml\..\xml\MyXml.xml (The system cannot find the path specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source)
How do I get the real path of the xml file.
Edited by: shashiwagh on Jan 29, 2010 11:46 AMHi,
if your XML file is inside a package you can easily get it from the classloader.
Note that your application maybe packaged inside a jar so it is not safe to use java.io.File for this purpose.
You have an xml file in :
com/gts/xml/MyXML.xml
in a class of the same module (that will packaged in the same jar) for example com.gts.java.XmlLoader :
// To get the stream :
InputStream is = this.getClass().getResourceAsStream("/com/gts/xml/MyXML.xml");
// Or the URL :
URL xml = this.getClass().getResource("/com/gts/xml/MyXML.xml");Hope it helps. -
Getting the unscaled length of
I'm developing a graphing application with FLEX 3 that will
be embedded into a PDF document (version 9). The graphing SWF is
pretty much finished, but I want to have greater control over the
scaling on the axis. If I graph the parametric equations x=cos(t)
and y=sin(t), the trace of these equations appears as an ellipse.
Is there some what if getting the unscaled length of the vertical
axis and the horizontal axis in pixels, so I can compute the exact
aspect ratio of the axes. If that is known, I can rescale using
scaleX and scaleY. Can anyone give me pointers?
dpsYou can simply iterate through each line in text to get the widest line. Something like this:
Main();
function Main() {
var text = app.selection[0],
minLength, maxLength, start, end;
for (var i = 0; i < text.lines.length; i++) {
start = text.lines[i].characters[0].horizontalOffset,
end = text.lines[i].characters[text.lines[i].characters.length-1].horizontalOffset;
if (minLength == undefined || start < minLength) {
minLength = start;
if (maxLength == undefined || end > maxLength) {
maxLength = end;
var length = maxLength - minLength;
$.writeln(length);
But this approach seems to be a little less precise than creating outlines since (I guess) it measures up to the beginning of the last character; discretionary hyphens, line brakes, etc. are not included into the measurement. -
HT201210 I had the ios 7 beta and now I cant figure out how to get the real update
I have the IOS 7 beta currently on my phone however now I can't figure out how to get the real update
Be sure to log into developer.apple.com using your developer ID. there should be support on these issues.
-
When we use the neew operator to make an array which method is called by the new operator and the length variable in arrays resides in which class
What?
-
How to get the real reason of bdb's err?
The application used some bdb's c-funcs, and get a err-log like below:
PANIC: fatal region error detected; run recovery
txn_checkpoint: log failed at LSN [1 6638626] DB_RUNRECOVERY: Fatal error, run database recovery
How to get the real reason of the err?
I tried to using db_printlog. But it print all the info of the log file. Another question is:
How to get the info of exact place?The question is still there. Could someone help me?
-
How to get the real name of a sender ?
When I receive a message under JavaMail, I want to get the real name of the sender but when I do a getFrom() I received a string like :
=?iso-8859-1?q?Julien=20Dupont?= <[email protected]>
But I only want the real name...
How can I do to recover only "Julien Dupont" ?
Thanks
Jujavax.mail.Address[] addrs= m.getFrom();
Address a = addrs[0];
if (a instanceof InternetAddress &&
((pers = ((InternetAddress)a).getPersonal()) != null)) {
String addr = ((InternetAddress)a).getPersonal();
} else
addr = a.toString();
this 'getPersonal()' is the thing you need. -
How to get spot channels colors data and get spot channels length
File is cmyk format..spot channel color is cmyk .such as an spot channel color is c100m50y20k5
how get spot channels color data use javascript? c=? m=? y=? k=?
howv to get spot channel length n(don't cmyk channel) use javascript? such as file cmyk + 7 spot channel n=7
pls help meYou may want to post over at:
Photoshop Scripting
And you may want to elaborate on what this is supposed to mean:
File is cmyk format..spot channel color is cmyk .such as an spot channel color is c100m50y20k5
Maybe posting screenshots with the relevant Panels visible might help illustrate the issue. -
M8020 how do I get the real OEM VISTA premium cds ?
M8020:
How do I get the real OEM VISTA premium cds ? processor fan enclosure (plastic) is broken, HP does not have part, Constant BSOD's, VIsta reports inaccurate errors, excessive loud fan noise. Looks like HP did NOT tested this platform well !fixmaipc,
The recovery discs are the only method HP supplies with which to install your operating system. That being said, there are also several repair options available on the recovery discs, including hardware diagnostics and startup repair. When you boot to the first recovery disc, choose advanced options, and it will provide you with the additional tools available for diangosing and repairing your PC.
Regards,
Although I am an HP Employee, the advice given here is my own, and not necessarily that of HP's.
Please post rather than send me a Message. It's good for the community and I might not be able to get back quickly. -
i am using pl/sql and i need to do some validation regarding the max length of the string. but the problem is that i have to refer back to the database for the length so that if the database change, my code don't change.
is there any way to get the max length in the field of the table?
eg:
lets say i got a table call Person with column Name(varchar2(66)) and Sex(char(1))
so how i retrieve the max length of the field Name?
thanksIt's quite simple. We can use the PL/SQL %TYPE in our declarations. Check it out...
SQL> CREATE TABLE small1 (col1 NUMBER, col2 VARCHAR2(3))
2 /
Table created.
SQL>
SQL> CREATE OR REPLACE PROCEDURE small1_api (pv_string IN VARCHAR2)
2 AS
3 l_col2 small1.col2%TYPE;
4 BEGIN
5 l_col2 := pv_string;
6 INSERT INTO small1 (col1, col2)
7 VALUES (a12.NEXTVAL, l_col2);
8 EXCEPTION
9 WHEN value_error THEN
10 dbms_output.put_line('oops! string is too long');
11 END;
12 /
Procedure created.
SQL> EXEC small1_api('APC')
PL/SQL procedure successfully completed.
SQL> EXEC small1_api('APC4')
oops! string is too long
PL/SQL procedure successfully completed.
SQL>
SQL> ROLLBACK
2 /
Rollback complete.
SQL> ALTER TABLE small1 MODIFY (col2 VARCHAR2(4))
2 /
Table altered.
SQL> ALTER PROCEDURE small1_api COMPILE
2 /
Procedure altered.
SQL>
SQL> EXEC small1_api('APC4')
PL/SQL procedure successfully completed.
SQL> EXEC small1_api('APC45')
oops! string is too long
PL/SQL procedure successfully completed.
SQL> Cheers, APC
Maybe you are looking for
-
Idoc Msg Type COND_A in MM condition transfer
Hi, Idoc message type COND_A is used to transfer condition records from one client to another using ALE.We can use t-code MEK3 to transfer PB00 condition type . Can anyone tell me which t-code is used to transfer condition types other than PB00 like
-
I have a form for use to enter data. The user might enter more one record at a time. Some information is need for the next record. So I don't want the form to clear the data each time the user click on the [Insert] button. I want the form to remain o
-
Cannot Save files to original file names to my computer?
I am getting errors when I try to save a file to my hard drive. The program is either denying access to save or saves to the hard drive under a different name. I have hundreds of files related to clients. I do not want re-name all my established file
-
Keywords after export - how to use them?
Hi, I´m organizing my RAW files using hierarchic keywords. LR exports them to IPTC when I export them to jpeg. Which database can easily make use of those keywords? I don´t want to type all those categories again... Thanks in advance
-
Can i download apps on my first generation ipod touch?
can i download apps on my first generation ipod touch?