Click here to Skip to main content
15,896,912 members
Home / Discussions / Java
   

Java

 
AnswerRe: Convert Fortran program to Java Pin
toxcct8-Oct-08 1:03
toxcct8-Oct-08 1:03 
QuestionHelp to set apache tomcat 6.0 to netbeans Pin
hamid zamani7-Oct-08 2:12
hamid zamani7-Oct-08 2:12 
AnswerRe: Help to set apache tomcat 6.0 to netbeans Pin
Pedram Behroozi8-Oct-08 7:08
Pedram Behroozi8-Oct-08 7:08 
QuestionCode Optimization Pin
TannerB6-Oct-08 12:02
TannerB6-Oct-08 12:02 
AnswerRe: Code Optimization Pin
toxcct6-Oct-08 21:26
toxcct6-Oct-08 21:26 
GeneralRe: Code Optimization Pin
TannerB7-Oct-08 7:04
TannerB7-Oct-08 7:04 
GeneralRe: Code Optimization Pin
toxcct7-Oct-08 7:11
toxcct7-Oct-08 7:11 
AnswerRe: Code Optimization Pin
douss7-Oct-08 23:19
douss7-Oct-08 23:19 
Hello everybody,

I would implement it like this to avoid if or switch statements :

int incrementAmount;
for(int i = 0;i < inputLength;i++){
	//input[i] gives a "The type of the expression must 
	//be an array type but it resolved to String", but
	//there is no need for '%60'

	currentLetter = input.charAt(i); 
	incrementAmount = (Character.toUpperCase(currentLetter)-'A')%9+1;
	firstNameTotal += incrementAmount;
}


Also we can replace :
incrementAmount = (Character.toUpperCase(currentLetter)-'A')%9+1;

By :
incrementAmount = (Character.toUpperCase(currentLetter)-'A')%('J'-'A')+1;


just to be more readable, that means "restart counting after the letter 'J'", which is better than "restart counting after the 9th letter".
I also just noticed that you don't manage the case where thirdNameTotal is equal to 0.
GeneralRe: Code Optimization Pin
toxcct8-Oct-08 0:34
toxcct8-Oct-08 0:34 
QuestionHelp with digest message using md5 algrothim Pin
omar el halwagy6-Oct-08 4:44
omar el halwagy6-Oct-08 4:44 
QuestionHow to debug MSJVM in Eclipse Pin
utnqbao6-Oct-08 0:50
professionalutnqbao6-Oct-08 0:50 
AnswerRe: How to debug MSJVM in Eclipse Pin
toxcct6-Oct-08 1:37
toxcct6-Oct-08 1:37 
GeneralRe: How to debug MSJVM in Eclipse Pin
utnqbao6-Oct-08 16:34
professionalutnqbao6-Oct-08 16:34 
GeneralRe: How to debug MSJVM in Eclipse Pin
utnqbao6-Oct-08 17:32
professionalutnqbao6-Oct-08 17:32 
QuestionDraw graph (networks) Pin
ventomito4-Oct-08 11:23
ventomito4-Oct-08 11:23 
AnswerRe: Draw graph (networks) Pin
douss7-Oct-08 23:38
douss7-Oct-08 23:38 
GeneralRe: Draw graph (networks) Pin
ventomito10-Oct-08 23:32
ventomito10-Oct-08 23:32 
Generaljava.util.List memory usage Pin
thrasher08154-Oct-08 10:55
thrasher08154-Oct-08 10:55 
Questionhow to close acceptandopen for streamconncetionnotifier Pin
manju23reddy2-Oct-08 18:16
manju23reddy2-Oct-08 18:16 
Questiontext twist game project help...... Pin
reanne_8830-Sep-08 21:20
reanne_8830-Sep-08 21:20 
AnswerRe: text twist game project help...... Pin
toxcct30-Sep-08 22:54
toxcct30-Sep-08 22:54 
GeneralRe: text twist game project help...... Pin
reanne_881-Oct-08 4:53
reanne_881-Oct-08 4:53 
Questionhi Pin
my data27-Sep-08 22:06
my data27-Sep-08 22:06 
AnswerRe: hi Pin
toxcct28-Sep-08 21:43
toxcct28-Sep-08 21:43 
QuestionKoch Snowflake Pin
vultron_322926-Sep-08 13:10
vultron_322926-Sep-08 13:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.