Results 1 to 3 of 3
Thread: Need help please with coding
- 12-23-2010, 02:27 PM #1
Member
- Join Date
- Dec 2010
- Posts
- 1
- Rep Power
- 0
Need help please with coding
Hello sorry for my bad english but i need your help. This is the code :
I need to change that similar words should be removed not changed to null please help.Java Code:public class TekstoTvarkymas { private String[] sakinys = new String[1000]; private String pirmasZodis; public TekstoTvarkymas(String pavadinimas) { Scanner scan = null; FileInputStream filein = null; try { filein = new FileInputStream(pavadinimas); scan = new Scanner(filein); sakinys = scan.nextLine().trim().split(" "); pirmasZodis = sakinys[0]; } catch (IOException ex) { System.out.println("Klaida skaitant faila " + pavadinimas); } finally { if (filein != null) scan.close(); } } public int pasikartoja() { int kartojasi = 0; for (int i = 0; i < sakinys.length; i++) if (sakinys[i] != null && sakinys[i].equalsIgnoreCase(pirmasZodis)) kartojasi++; return kartojasi; } public void naikintiPasikartojimus() { for (int i = 1; i < sakinys.length; i++) if (sakinys[i] != null && sakinys[i].equalsIgnoreCase(pirmasZodis)) sakinys[i] = null; } @Override public String toString() { String s = ""; for (String l : sakinys) if (l != null ) s += l + " "; return s; } }Last edited by Eranga; 12-24-2010 at 01:16 AM. Reason: code tags added
- 12-23-2010, 02:30 PM #2
Read this: How To Ask Questions The Smart Way
Specifically- what does your code do instead? Do you see Exceptions? Strange behavior? What were you expecting? What have you tried?
Code tags are your friend.
- 12-24-2010, 01:19 AM #3
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Similar Threads
-
does gui coding in netbeans is just the same with coding without nebeans?
By maizuddin35 in forum NetBeansReplies: 4Last Post: 10-25-2010, 03:49 PM -
Need help coding
By ace_03 in forum New To JavaReplies: 2Last Post: 11-25-2009, 05:16 PM -
Coding help
By Java_Fanatic in forum New To JavaReplies: 7Last Post: 10-15-2009, 04:37 AM -
Better coding
By tomiu in forum New To JavaReplies: 1Last Post: 04-09-2009, 07:19 PM -
coding help
By accies76 in forum New To JavaReplies: 5Last Post: 11-12-2008, 08:15 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks