Page 13 of 34 FirstFirst ... 31011121314151623 ... LastLast
Results 121 to 130 of 335
  1. #121

    Default Re: Java Programming


    @cen: wrong again! hehehe it isnt PrintForm, its PrintWriter anyway, i got hold of my problem. so, the step would be reading now the file. how do you delimit using three characters - "[", ",", and "]"?

    ill be using FileReader to "read" out the data then probably use StringTokenizer to delimit those three characters.

    next would be compare two arrays...
    Binary Search Tree...
    AVL Tree...
    Hash Table...
    Linked List..

    and more...

    im getting 3 hours of sleep every night

  2. #122

    Default Re: Java Programming

    Has anyone tried installing and running Java j2se in a 64 bit Linux box? I installed the standard j2se in a 64 bit CentOS and I can't run a gui application. I'm downloading the 64 bit version now but I can't see an i386 version, only an amd64 version is available. My processor is the intel EM64T

  3. #123

    Default Re: Java Programming

    Quote Originally Posted by javapenguin
    Has anyone tried installing and running Java j2se in a 64 bit Linux box? I installed the standard j2se in a 64 bit CentOS and I can't run a gui application. I'm downloading the 64 bit version now but I can't see an i386 version, only an amd64 version is available. My processor is the intel EM64T
    My java application ran successfully using the amd64 version of the jdk even with an Intel EM64T processor

  4. #124

    Default Re: Java Programming

    Quote Originally Posted by catch
    how do you delimit using three characters - "[", ",", and "]"?
    ill be using FileReader to "read" out the data then probably use StringTokenizer to delimit those three characters.
    Create a class that inherits StringTokenizer object and implements a Clonable. Override the obj.clone() method. After nimo ang instantiate ang imong class (class that inherits StringTokenizer object and implements a Clonable). clone the instance 2 times. So naa na ka'y 3 instance (including the original). Then use each delimiters to delimit the 3 instances.

    or

    instantiate 3 different StringTokenizer object with the same String parameter and use each delimiter to delimit the 3 instances.
    Code:
     StringTokenizer object1=new StringTokenizer("[Sample],[text],[from],[istoryans],[cen]",",");
        StringTokenizer object2=new StringTokenizer("[Sample],[text],[from],[istoryans],[cen]","[");
        StringTokenizer object3=new StringTokenizer("[Sample],[text],[from],[istoryans],[cen]","]");
        
        while(object1.hasMoreTokens()) {
          System.out.println(object1.nextToken());
          System.out.println(object2.nextToken());
          System.out.println(object3.nextToken());
        }

    Quote Originally Posted by catch
    next would be compare two arrays...
    Binary Search Tree...
    AVL Tree...
    Hash Table...
    Linked List..

    and more...

    im getting 3 hours of sleep every night
    Hahahah... keep solving the problem bro. You can do it. Mo-adapt rana ang imong brain. Kung ang tao nga mag-cge og lift sa weight magka-dako man gani ang lawas. Same rana sa atong brain. Once your brain is bombarded with different problems the neurons will re-arrange so that next time you will solve that problem faster. Pero kailangan mo sleep lang gyud ka og tarong. Take it from me.

    Quote Originally Posted by catch
    im getting 3 hours of sleep every night
    Good sleep makes good thinking brain. Pero dili gyud malikayan labi na nga mag-OverTime ka. Basta nindot ni organic nga brain ka'y naay ability nga mo-adapt..

  5. #125

    Default Re: Java Programming

    Quote Originally Posted by cen
    Pwede man sad ka mag-create parehas ani...
    Code:
    public class HerdOfAnimals implements java.io.Serializable {
    
      private Animal animal[];
    
      public void setAnimal(Animal animals[]) {
      // put some array of animals here...  
    }
    last nalng jud ni bro!! hehehehe
    unsaon pag put some array animals bro?? dli man gud ko kabalu kaayo sa array implementation sa java gud! pwede mangayo example?? k ra bro??


  6. #126

    Default Re: Java Programming

    Quote Originally Posted by jerx d great
    last nalng jud ni bro!! hehehehe
    unsaon pag put some array animals bro?? dli man gud ko kabalu kaayo sa array implementation sa java gud! pwede mangayo example?? k ra bro??
    Gamay nalang na nga problem bro. Makaya ra na nimo. Trust me.

  7. #127

    Default Re: Java Programming

    ok tanx!!

  8. #128

    Default Re: Java Programming

    i cant bare to detect the bug... whats wrong with my code?

    Code:
    import java.io.*;
    import java.util.*;
    
    class ReadRandomNumber {
    
    	public static void main (String [ ] args) throws IOException {
    
    	String fileName;
    
    	File inFile = new File("sample2.txt");
    	FileReader fileReader = new FileReader(inFile);
    	BufferedReader bufReader = new BufferedReader(fileReader);
    	String entryFromFile;
    
    	entryFromFile = bufReader.readLine( );
    	StringTokenizer tokens = new StringTokenizer(entryFromFile,",");
    
    	int numberOfTokens = 0;
    
    	while(tokens.hasMoreTokens( )) {
    		tokens.nextToken();
    		numberOfTokens++;
    	}
    
    	String [ ] arrayOfStringTokens = new String [numberOfTokens];
    	int [ ] arrayOfIntTokens = new int [numberOfTokens];
    
    	for(int index = 0; index <= numberOfTokens; index++) {
    		tokens.hasMoreTokens( );
    		arrayOfStringTokens[index] = tokens.nextToken( );
    		arrayOfIntTokens[index] = Integer.parseInt(arrayOfStringTokens[index]);
    		System.out.print(arrayOfIntTokens[index]); 
    	}
    	
    	bufReader.close( );
    	
    	}
    }
    the code simply reads the numbers from "sample2.txt" and puts it in an array. but it seems that my arrays doesnt work... i welcome suggestions.

    thanks!

  9. #129

    Default Re: Java Programming

    Code:
    	
    while(tokens.hasMoreTokens( )) {
    		tokens.nextToken(); 
    		numberOfTokens++; 
    	}
    Useless bro. Better use int tokens.countTokens();. This returns total number of tokens.

    Now look...

    Code:
    	
    while(tokens.hasMoreTokens( )) {
    		tokens.nextToken(); // Note 1
    		numberOfTokens++; 
    	}
    Code:
    for(int index = 0; index <= numberOfTokens; index++) {
    		tokens.hasMoreTokens( );
    		arrayOfStringTokens[index] = tokens.nextToken( ); // Note: 2
    		arrayOfIntTokens[index] = Integer.parseInt(arrayOfStringTokens[index]);
    		System.out.print(arrayOfIntTokens[index]); 
    }
    Note 1: Nag-cge ka og gamit sa tokens.nextToken();. Remember ni move ang cursor position ani.
    Note 2: Used up na ang cursor sa while loop nimo. So mo-throw ni siya og exception.

    better.... use this!

    wait!



  10. #130

    Default Re: Java Programming

    Try this. It works sa ako...

    Code:
    public static void main (String [ ] args) throws IOException {
    
    	File inFile = new File("C:/cen.txt");
    	FileReader fileReader = new FileReader(inFile);
    	BufferedReader bufReader = new BufferedReader(fileReader);
    	String entryFromFile;
    
    	entryFromFile = bufReader.readLine( );
    	StringTokenizer tokens = new StringTokenizer(entryFromFile,",");
    
        
    	String [ ] arrayOfStringTokens = new String [tokens.countTokens()];
    	int [ ] arrayOfIntTokens = new int [tokens.countTokens()];
                  
    	for(int index = 0; index < arrayOfStringTokens.length ; index++) {
    		arrayOfStringTokens[index] = tokens.nextToken( ); 
    		arrayOfIntTokens[index] = Integer.parseInt(arrayOfStringTokens[index]);
    		System.out.println(index +" " + arrayOfIntTokens[index]); 
    	}
    	
    	bufReader.close();
    }

  11.    Advertisement

Page 13 of 34 FirstFirst ... 31011121314151623 ... LastLast

Similar Threads

 
  1. JAVA PROGRAMMING *****
    By bardnekom in forum Programming
    Replies: 20
    Last Post: 04-18-2013, 12:51 PM
  2. MOVED: JAVA PROGRAMMING *****
    By vern in forum Software & Games (Old)
    Replies: 0
    Last Post: 03-23-2008, 02:43 AM
  3. Java programming help pls...
    By mr_gwen in forum Programming
    Replies: 6
    Last Post: 11-03-2006, 12:30 AM
  4. nid help..java programming
    By ronninalpha in forum Programming
    Replies: 3
    Last Post: 09-13-2006, 07:55 PM
  5. MOVED: Java Programming
    By BadDudes in forum Software & Games (Old)
    Replies: 0
    Last Post: 04-28-2006, 12:04 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top