thePhantom's Profile User Rating: -----

Reputation: -1 Dishonored
Group:
Active Members
Active Posts:
60 (0.05 per day)
Joined:
28-April 10
Profile Views:
1,186
Last Active:
User is offline Apr 23 2012 12:29 PM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   thePhantom has not set their status

Posts I've Made

  1. In Topic: Using string.split to split string, but print string on same line

    Posted 25 Mar 2012

    Ok, so I managed to come up with:
            	String []array=strLine.split("\n");
            	for(String s: array)
            	{
            		System.out.println(s);
            	}
    
    

    ...which seems to work. Any hints on how I could sort the ints (with attached strings) in ascending order, without changing the order of the strings :)?

    I am actually required to use a BST, and although I've read through some tutorials, I still can't seem to understand the application of it...
  2. In Topic: Using string.split to split string, but print string on same line

    Posted 25 Mar 2012

    I did try that, but then it prints everything on one line without spaces, i.e.:

    1catsdogs2menwomen3applespears4bricksstones
    
    


    :/

    Also, some of the words aren't alphabetically, but I don't want to sort that out... The strings must only be re-arranged based on their key/int values
  3. In Topic: Binary Search tree of text file

    Posted 24 Mar 2012

    Uhm, it's actually compulsory for me to use the BST though... That's why I was trying to figure out a way to use String Tokenizer
  4. In Topic: Binary Search tree of text file

    Posted 24 Mar 2012

    So I tried using the String split (never used it before):

        while ((strLine = br.readLine()) != null)   
        {
            String firstWord, restOfString=" ";
            
            String [] aSplit= strLine.split (" ");
            firstWord=aSplit[0];
            
            for (int i=1; i<aSplit.length; i++)
            {
            	restOfString += aSplit[i];
            	restOfString += " ";
            	
            	System.out.println (firstWord + restOfString);
            	}
        }
    
    


    But my prints out:

    3 apples
    3 apples pears
    1 cats
    1 cats dogs
    4 bricks
    4 bricks stones
    2 men
    2 men women
    
    


    Any suggestions?
  5. In Topic: Sequential Search method

    Posted 4 Mar 2012

    I tried
     public static String [] readFile (String fileName) throws IOException
       {
    Scanner s = new Scanner (new FileReader (fileName));
    	 while (s.hasNextLine()) {
         String [] file = scanner.nextLine();   
           { int i=0;
             file[i] = s.nextLine ();
          }
          s.close ();
          return file;
          }
       } 
    


    It says "Exception in thread "main" java.lang.Error: Unresolved compilation problem:
    scanner cannot be resolved"

My Information

Member Title:
D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Click here to e-mail me

Friends

thePhantom hasn't added any friends yet.

Comments

Page 1 of 1
  1. Photo

    king_009 Icon

    04 Sep 2010 - 23:12
    :) thanks for the wishes buddy!!!
Page 1 of 1