boolean [] deleteItem = new
boolean[[Link]];
int size=0;
for(int i=0;i<[Link];i==){
if(arr[i].equals("a")){
deleteItem[i]=true;
}
else{
deleteItem[i]=false;
size++;
}
}
String[] newArr=new String[size];
int index=0;
for(int i=0;i<[Link];i++){
if(!deleteItem[i]){
newArr[index++]=arr[i];
}
}
answered Sep 22 '08
edited Sep 22 at 12:50
link|flag '08 at 13:06
shsteimer
2,574●9●38
arrgh can't get code to show up correctly.
0
sorry got it working. sorry again i don't
think I read the question properly
String foo[] =
{"a","cc","a","dd"},
remove =
"a";
boolean gaps[] = new
boolean[[Link]];
int newlength = 0;
for(int c =
0;c<[Link];c++)
{
if(foo[c].equals(remove))
{
gaps[c] =
true;
newlength+
+;
}
else gaps[c] =
false;
[Link](foo[c]);
}
String newString[] = new
String[newlength];
[Link]("");
for(int c1=0,c2=0
;c1<[Link];c1++)
{
if(!gaps[c1])
{
newString[c2] = foo[c1];
[Link](newString[c2]);
c2++;
}
}
Object
public class Weekend {
public static void main(String [] args) {
// Set up a series of film objects
Film Watch[] = new Film[4];
Watch[0] = new Film("Shrek",133);
Watch[1] = new Film("Road to Perdition",117);
Watch[2] = new Film("The Truth about Cats and Dogs",93);
Watch[3] = new Film("Enigma",114);
Film Longest = null, Shortest = null; // To avoid a grumpy compiler
int longtime = 0, shorttime = 0; // To avoid a grumpy compiler
for (int i=0; i<[Link]; i++) {
int mins = Watch[i].getminutes();
if (i == 0) {
Shortest = Longest = Watch[i];
shorttime = longtime = mins;
} else {
if (mins < shorttime) {
shorttime=mins;
Shortest = Watch[i];
}
if (mins > longtime) {
longtime=mins;
Longest = Watch[i];
}
}
}
[Link]("Longest film is " +
[Link]() +
" at "+longtime+" minutes");
[Link]("Shortest film is " +
[Link]() +
" at "+shorttime+" minutes");
}
}
hi james
solution is
child [] children=new child[5];
classname[] arrayname=new classname[no of objects];
then u write
child[0]=new child(23);
classname[objectnumber]=new classname(age);
child(23) is a parameterized construtor of class child.
this should solve ur problem...
do let me know when ur done
File Save DAT file
try
{
String filename= "[Link]";
boolean append = true;
FileWriter fw = new FileWriter(filename,append);
[Link]("add a line\n");//appends the string to the file
[Link]();
}
catch(IOException ioe)
{
[Link]("IOException: " + [Link]());
}