Jump to content


Check out our Community Blogs

Mozana

Member Since 03 May 2010
Offline Last Active Jan 10 2016 09:19 AM
-----

Posts I've Made

In Topic: Tutorial: How to load webpage dynamically using innerHTML?

26 March 2012 - 04:37 AM

nyc +rep[COLOR="Silver"]

In Topic: Scanner/useDelimiter help

28 February 2012 - 12:19 AM

Change your list declaration to
ArrayList<Integer> list;
so inside the for you can do this
for(Integer num : list)
{
and do your stuff here, the comparison
}
I think the comparison is what appears to be tricky to you let me see if I can help with that.

---------- Post added at 08:19 AM ---------- Previous post was at 07:54 AM ----------

Ok the sorting was not the only problem, I altered your code a little.

import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;

public class integerCount {

    public static void main(String[] args) {
        Scanner scanner1 = new Scanner(System.in);
       [B] [B]ArrayList<Integer> list = new ArrayList();[/B][/B]
        String input = null;
        int temp = 0, count = 0;

        System.out.print("Enter a list of numbers ending with -999: ");
        input = scanner1.nextLine();
       [B] String [] nums = input.split(" ");[/B]
        //break the string into integers and put into an 
      [B] [B] for(int i = 0; i < nums.length;i++)
        {
            temp = Integer.parseInt(nums[i]);
            if(temp != -999)
            {
                list.add(temp);
            }
            break;
        }[/B][/B]
        //sort the list in ascending order
        Collections.sort(list);
        //output
     [B]  [B] for (Integer n : list) {
            System.out.println(n);
        }[/B][/B]
    }
}
The code now does recognise the numbers as individual numbers how ever you still have to deal with the sorting.

In Topic: Scanner/useDelimiter help

27 February 2012 - 11:51 PM

      while(list.get(x+1).equals(list.get(x))){
        count++;
        x++;
      }
I have a feeling that is where you have the error. here ()
the statement list.get(x+1) is throwing you out of the bounds.
I would suggest you use a for(Object obj : obj) however seeing you are working with int type I suggest the following.

In Topic: Sqlite locked

10 February 2012 - 05:53 AM

lol yea, I also kept calling the
closeConnDB();
which duz close the method, but yea I am now using sqljet

In Topic: Sqlite locked

09 February 2012 - 10:53 PM

the thing is even if I set the connection to null and reinitialise it the exception is thrown, guess Ill try a different db, Thank you man

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download