Originally posted by mandy fern:
public class number
{
public int[][] array2D = {
{ 1, 2, 3 ,4 , 5},
{ 6, 7, 8, 9, 10},
{ 11, 12, 13, 14, 15},
{ 16, 17, 18, 19, 20}
};
{
int a= Console.readInt("add a number");
array2D[0][0]=a;
int b= Console.readInt("add a number");
array2D[0][1]=b;
int c= Console.readInt("add a number");
array2D[0][2]=c;
int d= Console.readInt("add a number");
array2D[0][3]=d;
int e= Console.readInt("add a number");
array2D[0][4]=e;
int f= Console.readInt("add a number");
array2D[1][0]=f;
int g= Console.readInt("add a number");
array2D[1][1]=g;
int h= Console.readInt("add a number");
array2D[1][2]=h;
....etc
My question is:Is there a way to shorten this or do I have to to do this
for every component of the array?
Originally posted by Buck_Webb:
I am looking at a copy of "just JAVA 2", Fourth Edition.
On page 384 it shows a table for the Java.util API. In the table is listed the area of Calendar,TimeZone,SimpleTimeZone.
On page 404 is the following code:
TimeZone z_ect = TimeZone.getTmeZone("ECT");
GregorianCalendar g2 = new GregorianCalendar(z_ect);
g2.set(89, 10, 9, 19, 0); // Berlin Wall //Down Nov 9 1989 7pm
g2.set(89, Calendar.NOVEMBER, 9, 19,0); //better
I don't know if this is what you need, but give it a try.
Good Luck!
Eric
[This message has been edited by Eric Edwards (edited July 13, 2001).]
[/B]
Originally posted by kaffo lekan:
Hello
i need to know if a final variable can be changed at runtime.
Yes/No , please explain more.
Originally posted by gayathri bhushan:
Your class path should begin with .;C and so on.
You must put a .; before the C in your clas path for it to work.
Good Luck!
Originally posted by greggg smith:
I just bought the book after going through "Just Java 2".
It appears to be well done.
What I like about it is the code examples, the different approach to teaching Java, and especially the exercises at the end of each chapter.
Yes, it is laid out like a text book, but it is good for self-teaching.
I bought it at Barnes & Noble for $68.
Well worth it!
Originally posted by John Collie:
I ran your program as is and it works fine.
You need to run this program from a DOS command line.
I compiled your program and typed in:
java bank 4000 1700
It returned the correct information.
One thing though, class names should begin with a capital letter.
class bank should be class Bank.
Good Luck!
Originally posted by Asheesh_talwar:
I am getting a string with follwing formats
23434
2.32453
223,324,343.34532424
324,343.34532424
2.3453E-01
32,456.9
0
1.0
Note:The Number can be negative also.
First I want to check whether the number is postive or negative
Secondly I want to round the value to two decimal place.
Thirdly I want to display the number in the million format.
Regards
Asheesh
Originally posted by Asheesh_talwar:
Eric there is a problem with the solution that U have given
It will give correct o/p if we give two command line parameters.
The program will fail if we give less than two or greator than two parameters.
If we want it to work for any number of parameters then I think this will do.
class AddString
{
private void sumReturn(String args[])
{
String str = new String();
int i = 0;
if (args.length > 0)
{
for (int j = 0; j < args.length; j++)
{
str=str+args[j];
}
for(i = 0; i < args.length - 1; i++)
{
System.out.print(args[i] + "+");
}
System.out.println(args[i] + " = " + str);
}
}
public static void main(String args[])
{
AddString a = new AddString();
a.sumReturn(args);
}
}
Regards
Ashish
[Added spaces after '<' and elsewhere so that browsers don't confuse your code with HTML - Jim]
[This message has been edited by Jim Yingst (edited December 09, 2000).]