Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > Servlets
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Servlets section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 27th, 2004, 01:53 PM
Registered User
 
Join Date: May 2004
Location: Chattanooga, TN, USA.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Reusing String Arrays


  I am trying to reuse an array where eventually I am going to put AIX commands but I get compile errors when I try to reuse it. I am a newborn to Java. I don't want to enter the elements on an item by item basis and would rather not create a seperate array.

Excerpt

     // Create an Initial version of Command Array
     String[] command = { "a", "b", "c"};

     // Now try to reuse it to store new values. This is wrong
     command = {"d", "e", "f"};


Full Code is below..

import java.io.*;
import java.net.*;
import java.util.*;
import java.text.*;

public class arrays
{
  public static void main(String[] args)
 {
  try{

     // Create an Initial version of Command Array
     String[] command = { "a", "b", "c"};

     // Now try to reuse it to store new values. This is wrong
     command = {"d", "e", "f"};
    }
    catch( Exception e )
     { e.printStackTrace(); }
 }
}

Upon Trying to compile this I get the following Error Message:

arrays.java:18: illegal start of expression
     command = {"d", "e", "f"};
               ^
Reply With Quote
  #2 (permalink)  
Old May 28th, 2004, 04:11 AM
Registered User
 
Join Date: Jan 2004
Location: hyderabad, andhra pradesh, India.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to uskiranj
Default

String[] command = { "a", "b", "c"};with this u have created an array of Strings
command[0] points to String instance "a"
command[1] ------>"b"
command[2] ------>"c"
command[3] ------>"d"

unlike in c/c++, in java there is no such pointer which points to the starting element in the array.
that's why we are not able to assign the one more arry to that
but it's valid in c/c++.

because of its an array of instances u can give the String variables at the time of initialisation only.able to modify the existing String

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Question on reusing code billb VBScript 0 August 18th, 2006 10:39 AM
reusing querys jc188 Beginning PHP 3 April 1st, 2006 02:28 AM
Reusing Images hugh@kmcnetwork.com Classic ASP Basics 0 July 19th, 2004 02:58 PM
AutoNumber Reusing numbers chelst1 Access 3 July 5th, 2004 03:44 PM



All times are GMT -4. The time now is 06:21 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.