java - Iterating Numbers and Alphabet for hashmap -


i'm trying associate each letter of alphabet corresponding number. 0=a, 1=b, 2=c, etc.

although numbers sequencing properly, letters coming out "z." doing wrong (with loop)?

public static void ciphermap (map<integer, character> map) {     (int = 0; <= 25; i++) {          (character alphabet = 'a'; alphabet <= 'z'; alphabet++) {             map.put(new integer(i), alphabet);         }        } } 

output:

0: z 1: z 2: z 3: z 4: z 5: z ... on 

the last step of inner loop sets every i z. remove inner loop , like,

public static void ciphermap (map<integer, character> map) {     (int = 0; <= 25; i++) {          map.put(i, (char) ('a' + i));        } } 

Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -