Stop prefixing all your variables with the type - that's stupid. Stop it. Someone probably told you at some point that it was Hungarian notation and you should use it - that person was wrong. It's neither Hungarian notation, nor should you use it.

And if you write Java, you should try and strive to follow Java's coding style since there is actually an official style: http://www.oracle.com/technetwork/java/javase/documentation/codeconvtoc-136057.html
String.characterAt(x). You can compare characters directly with ==, <, >, etc.
@souvik; So with your line of code above, the variable s is equal to the first digit in the file right?
joshie75 wrote:
@souvik; So with your line of code above, the variable s is equal to the first digit in the file right?


No, it refers to a Scanner, that can then be used to get the first digit of the file.
@kllr; sorry to offend you D: I thought that's how everybody did it but I guess not; I'll try and convert Smile

@Shka; So If I have a string "Numbers" I can call this command to say, compare the i value of a string to a variable?


Code:

If (Numbers.characterAt(i) == somenumber)
     {
             ...Some code...
     }
It's not characterAt(), it's charAt(). You would want to either input as a string and use the String methods to convert it to a character, or input as an integer and use Integer.parseInt() or simply subtract 0x30 from the character value after typecasting it as a int.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 2 of 2
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement