Skip to Content
Real World XML
book

Real World XML

by Steven Holzner
January 2003
Beginner to intermediate content levelBeginner to intermediate
1200 pages
23h 42m
English
Peachpit Press
Content preview from Real World XML

Creating Arrays in Java

Simple data types of the kind we saw in the previous section are fine for storing single data items, but data is often more complex. Like JavaScript, Java supports arrays as well. Here's an example. In this case, I'll store the balances in customers' charge accounts in an array named chargesDue. I start by declaring that array, making it of type double:

public class ch10_04 
{
    public static void main(String[] args)
    {
        double chargesDue[];
    .
    .
    .

Besides declaring the array, you have to allocate the number of elements you want the array to hold. You do that using the new operator:

public class ch10_04 
{
    public static void main(String[] args)
    {
        double chargesDue[];
        chargesDue = new double[100];
    .
    .
    .

You can combine the ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Inside XML

Inside XML

Steven Holzner
XML Hacks

XML Hacks

Michael Fitzgerald

Publisher Resources

ISBN: 0735712867Purchase book