Forum: Java Jul 17th, 2009 |
| Replies: 8 Views: 646 Hi.
Well, at first - you don't change the "index" variable from the time, when it was created. You should specify the current index (since you're displaying not the first record of your array).
... |
Forum: Java Jul 17th, 2009 |
| Replies: 14 Views: 494 Using "array[number]" you're refer to 1 single element in array, which has a position [B]number-1[B] (since the array indexes are starting from 0).
If you need to pass whole array - pass just the... |
Forum: Java Jul 15th, 2009 |
| Replies: 19 Views: 498 How about use this:
arr[i+1][j]=sum;
instead of:
arr2[i+1][j-1]=sum; |
Forum: Java Jul 15th, 2009 |
| Replies: 19 Views: 498 uhu .. what if you would use just "j" (considering that you're extracting 1 from "x" on your next steps):
arr2[i+1][x-1]=sum;
System.out.print(arr2[i+1][x-1]); |
Forum: Java Jul 15th, 2009 |
| Replies: 19 Views: 498 Ok, good job.
But your code still remain tricky:
int arr[][]=new int[20][20];
int arr2[][]=new int[20][20];
Look, you missed the main thing of using 2 dimensional array. The point is: while... |
Forum: Java Jul 15th, 2009 |
| Replies: 19 Views: 498 I can help (that's what I'm actually do) .. but the ready-made code won't make from you
.. till you won't fully understand it.
If you interested - I can explain the jagged array for you. If you... |
Forum: Java Jul 15th, 2009 |
| Replies: 19 Views: 498 You won't program it correctly till you get the details of how it works. Let's unwrap the cycles. No indexes and such .. just the way, how it should go:
there's 2 things I've changed to make it more... |
Forum: Java Jul 15th, 2009 |
| Replies: 19 Views: 498 No, I can't, because We only give homework help to those who show effort (http://www.daniweb.com/forums/announcement9-2.html) |
Forum: Java Jul 15th, 2009 |
| Replies: 19 Views: 498 Hey, akulkarni.
There're some logic errors:
1. for(j=5;j>0;j--)
{
i=0;
while(i<5)
{
int c=arr[i][j]+arr[i][j-1];
System.out.print(c);
i++; |
Forum: Java Mar 15th, 2009 |
| Replies: 7 Views: 764 Well, if follow your's app logic: the Category must be a part of the Item (belongs to it). So if I were you - I would place the definition of it in Item class. And then import it from that class for... |
Forum: Java Mar 15th, 2009 |
| Replies: 7 Views: 764 Ok, in this place you can use simple construction, like:
category = eCategory.valueOf(scanToken.next()); |
Forum: Java Mar 15th, 2009 |
| Replies: 7 Views: 764 Hello, kbullard516. I was playing around with your code. Here's what I have so far:
(simply I've turned your words in code :P )
public int compareTo(Object other)
{
String otherName =... |
Forum: Java Jan 29th, 2009 |
| Replies: 9 Views: 534 When you do this:
Person vn = new Person("dingh","Ding");
you initialize only two fields, calling this:
Person(String brukernavn, String navn) {
this.brukernavn = brukernavn;
... |
Forum: Java Jan 22nd, 2009 |
| Replies: 5 Views: 712 Just to add: you can use the alternative way (a bit longer, but still can be useful some day :) ). For the case, if you don't want to interrupt your prog when the user inputs the incorrect value. You... |
Forum: Java Jan 19th, 2009 |
| Replies: 14 Views: 1,743 It happened because you calling maxF and maxC methods before you are filling arrays inputFahr and inputCel with data. And your maximum goes through arrays, filled by default values (in your case it's... |
Forum: Java Jan 6th, 2009 |
| Replies: 2 Views: 308 1. Are you sure, that your example is correct 2,15,4 which = 2,3,4 ... and not 16 = 3?
2. You don't check the case, when you get, for example 4,2,3. In that case your (x == 2) and (ex == 1), but it... |
Forum: Java Jan 4th, 2009 |
| Replies: 11 Views: 655 If I were you, I would probably do that:
1. Create a class, that will represent a single card (it will contain rank, suit). I suppose it will be better to use enum to list all possible suits and... |
Forum: Java Jan 4th, 2009 |
| Replies: 11 Views: 655 Hello, javaman2. You have mistake in logic here:
if(((x==1)&&(cardSuit==0))&&((x==2)&&(cardSuit==0) )&&((x==3)&&(cardSuit==0)))
All that expression contains only '&&' condition. So if a bit... |
Forum: Java Dec 22nd, 2008 |
| Replies: 13 Views: 1,040 I have a little variation on your 'old' code. It is not the best solution, but it is better than nothing. You can analyse it and make summary for yourself:
public void fillBoard()
{
... |
Forum: Java Dec 22nd, 2008 |
| Replies: 13 Views: 1,040 So your question is solved? If so, please mark thread as solved :) |
Forum: Java Dec 22nd, 2008 |
| Replies: 13 Views: 1,040 Hello, llemes4011.
Hm ... interesting task. Your problem here:
// If the number already appears in the row and the column, change the booleans to false to check again... |
Forum: Java Dec 17th, 2008 |
| Replies: 11 Views: 804 or one more example placed here:
http://www.exampledepot.com/egs/java.io/GetFiles.html |
Forum: Java Dec 6th, 2008 |
| Replies: 5 Views: 1,718 Hello, mrjoli021
I hope the Sun description of Runtime class help you:
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Runtime.html |
Forum: Java Nov 27th, 2008 |
| Replies: 10 Views: 4,165 Hello Sandawg,
Your thread name is "Printing array contents". If this question is already solved, please mark it solved. About sorting: try to do it yourself, if there are will appear any troubles -... |
Forum: Java Nov 27th, 2008 |
| Replies: 10 Views: 4,165 Just to add to what I and Stultuske are saying, here is an example for you:
You have method:
public static void printArray(int count)
{
for (int i=0; i<count; i++ )
{
... |
Forum: Java Nov 26th, 2008 |
| Replies: 10 Views: 4,165 Hello, Sandawg.
Beforehand sorry for my english .... :)
Here is my recommendations. Yoy must try to use static variables not so much as you do :) One of the classics said (If I'm not... |
Forum: Java Nov 26th, 2008 |
| Replies: 10 Views: 4,165 I saw. But this try didn't helped me to read normally his code. ;) |
Forum: Java Nov 26th, 2008 |
| Replies: 10 Views: 4,165 Hello, Sandawg.
Here is your mistake: you trying to take element of array, that not exists.
you should use this
public static void printArray(int count)
{
for (int i = 0; i<count; i++ )
{... |
Forum: Java Nov 26th, 2008 |
| Replies: 5 Views: 1,138 You should realize interface Comparable in your class Person. After that you'll can compare your objects, like that:
Person a, b;
a = ...;
b=...;
a.CompareTo(b);
This will allow you to sort... |
Forum: Java Nov 26th, 2008 |
| Replies: 5 Views: 1,138 Here is link to understand Comparable Interface:
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Comparable.html
And here is a little help on binary search:... |
Forum: Java Nov 24th, 2008 |
| Replies: 13 Views: 2,235 I've tried to run your code ... it's working. Try to rebuild your project. |
Forum: Java Nov 21st, 2008 |
| Replies: 6 Views: 4,152 You can use scanner.next() it returns string, but you can convert it to char. |
Forum: Java Nov 21st, 2008 |
| Replies: 6 Views: 4,152 Scanner has no definition of method getChar. |
Forum: Java Nov 19th, 2008 |
| Replies: 7 Views: 500 You can output them:
System.out.println(application2.setHours(input.nextInt()));
or check, if the setting passed correctly
if(application2.setHours(input.nextInt())))
{//all good}
else... |
Forum: Java Nov 19th, 2008 |
| Replies: 7 Views: 500 Correct me, if I'm wrong:
1. You creating new "clock" and setting it to 0.
Time application = new Time();
application.TimeTest(0, 0, 0);
2. Then while setting the hours creating 2 more... |
Forum: Java Nov 16th, 2008 |
| Replies: 7 Views: 1,294 As I understood, you have combined information in your file "books.txt" (name -
string and price - double). To split information, that was read from your file you should use patterns (in example... |
Forum: Java Nov 16th, 2008 |
| Replies: 7 Views: 1,294 Here is something, that can help you:
http://www.java2s.com/Code/JavaAPI/java.util/ScanneruseDelimiterStringpattern.htm |
Forum: Java Nov 8th, 2008 |
| Replies: 28 Views: 1,737 Beforehand I'm sorry for my English...
I don't know any way to dynamically create variable, but I can offer some alternatives:
1. Use Dictionary
2. Create class variable dynamicly |