473,320 Members | 2,024 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to print the length in array?

Expand|Select|Wrap|Line Numbers
  1. public class Array {
  2.  
  3.        public static void main (String[] args)
  4.        {
  5.        String [] sign = new String[]{"Fire", "Earth", "water"};
  6.  
  7.           System.out.print(sign.length);
  8.  
  9.     }
  10. }
  11.  
i want to print the length of the string which is located at the second element of the array. My output should be 2. how to get it? thanks :)
Dec 26 '13 #1

✓ answered by Luuk

I dont know how to get 2 but try:
Expand|Select|Wrap|Line Numbers
  1. System.out.print(sign[1].length());
This will print the length of 'Earth'

1 1372
Luuk
1,047 Expert 1GB
I dont know how to get 2 but try:
Expand|Select|Wrap|Line Numbers
  1. System.out.print(sign[1].length());
This will print the length of 'Earth'
Dec 26 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Stephen | last post by:
I have two arrays: int array1 = { { 1, 2, 3 }, { 4, 5, 6 } }; int array2 = { { 1, 2 }, { 3 }, { 4, 5, 6 } }; I need to print both of them by column like this:
4
by: Shailesh | last post by:
Hi! I want to overload << operator so that it can print an arry defined in MyClass.My problem is that I want to print only a no of elements NOT all the elements in the array and this no of...
18
by: Xiangliang Meng | last post by:
Hi. void setValue(int n) { int size = getValueLength(); int buffer_p; if (buffer_p) { ....
5
by: dam_fool_2003 | last post by:
Hai, I studied that the array size is fixed. But I come across a word called "variable length array". Is it possible to change the array size? So I tried the following: #include<stdio.h>...
10
by: Adam Warner | last post by:
Hi all, With this structure that records the length of an array of pointers as its first member: struct array { ptrdiff_t length; void *ptr; };
8
by: Fernando Barsoba | last post by:
Hi, I decided to start a new topic about my memory allocation question. One of the answers was that variable length arrays are possible using C99. I found this topic that also mentions it. ...
1
by: moonriver | last post by:
I intend to generate a variable-length array, similar to link lists in plain C. For example, I define the following array int a Initially I assign 5 elements to the array as a = new int...
8
by: lovecreatesbeauty | last post by:
Hello experts, I have seen following the code snippet given by Marc Boyer (with slight changes by me for a better format), and have doubts on it. I am so grateful if you can give me your kindly...
5
rahulephp
by: rahulephp | last post by:
Hi I need to print below array in the following manner. Output would be: Property Name: 1 Property Address: 1 Price: 1 Property Size: 1 URL 1
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.