Lost Password?


Go Back   CodeCall Programming Forum > Software Development > Java Help

Java Help Java Help forum discussing all Java platforms - J2ME, J2SE and J2EE - as well as relevant standards, APIs and frameworks such as Swing, Servlets, JSPs, Applets, Struts, Spring, Hibernate, ANT, EJB, and other Java-related topics.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-19-2007, 01:15 PM
idgeitman idgeitman is offline
Newbie
 
Join Date: Apr 2007
Posts: 2
Rep Power: 0
idgeitman is on a distinguished road
Default Objects..

Hey all,

I've been giving objects a try, but i tryed to make a little search function and it doesn't seem to be working out,


Code:
	static void mod(Vector v) {
    
     System.out.print("Reg to search: ");   
      
      String readx = new String();
         Keyboard.skipLine();
         readx = Keyboard.readString();
        
        
        	for(int i = 0; i < v.size(); i++) {

             Object p = v.elementAt(i);
              car c2 = (car)p;	
              	
    if(c2.reg == readx) 
     	 System.out.println(c2.make + "\t:\t" + c2.reg + "\t:\t" + c2.numdays + "\t:\t" + "E " + c2.cost + "\n");
   
         }
Thats the main program code, The car class is has a String called "reg" inside it. What im trying to do is get it to downcast and then compare the readx to the c2.reg and if it matches, then print out that object,

Any help would be great!

Thanks,

~ Idgeitman

Last edited by idgeitman; 04-19-2007 at 01:18 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 04-20-2007, 10:58 PM
John's Avatar   
John John is offline
Co-Administrator
 
Join Date: Jul 2006
Age: 20
Posts: 3,470
Last Blog:
Joomla! And Incompeten...
Rep Power: 20
John has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond repute
Send a message via AIM to John Send a message via MSN to John
Default

are readx to the c2.reg strings?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-22-2007, 04:54 AM
idgeitman idgeitman is offline
Newbie
 
Join Date: Apr 2007
Posts: 2
Rep Power: 0
idgeitman is on a distinguished road
Default

c2.reg is also a string
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-22-2007, 11:42 PM
John's Avatar   
John John is offline
Co-Administrator
 
Join Date: Jul 2006
Age: 20
Posts: 3,470
Last Blog:
Joomla! And Incompeten...
Rep Power: 20
John has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond repute
Send a message via AIM to John Send a message via MSN to John
Default

I believe strings are objects and should therefor use the .equals() method to compare rather than the == operator
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
G++ Error: cannot pass objects of non-POD type Ronin C and C++ 4 10-01-2007 05:35 AM
[Query]TreeMap and TreeSet objects. How to use? Musashibo Java Help 0 06-05-2007 10:18 AM
Java:Tutorial - Adding more objects to your window John Java Tutorials 0 01-11-2007 03:09 PM
Classes, Methods, and Objects Sionofdarkness Java Help 6 08-21-2006 01:55 PM
Objects Nightracer General Programming 8 07-28-2006 09:02 PM


All times are GMT -5. The time now is 11:25 PM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 100%


Complete - Celebrate!

Ads