im running this code and im having trouble understanding theerror the complier is giving me ...........can u please tell me howto fix it?for (int i=0; i<word.length(); i++) {Node node = new Node();char alpha = word.charAt(i);*** int index = alpha.getNumericValue(); ***branch[index - 97] = node;Node[] branch2 = new Node[27] ;node.next = branch2;for the line in between the stars i get the Error Messege:"char cannot be dereferenced"can u please tell me what to do ?
The problem is that "char" is not a class, is aprimitive type, so you can't call methods on a"char" variable, if you want to convert a charinto an int, you can do this casting:int index = (int) alpha;
if have called import java.lang.* at the begining then tryint index=Character.getnumericvalue(alpha); I hope this will solve yrproblem...PLz do let me know if it works as I am also in the process oflearning and hopefully this will help me as well..
well I amnot an experienced java programmer but hopefully this solution willsolve yr problem.If u have included java.lang library at the begining. then replace yr codein stars! withint index = character.getnumericvalue(alpha); I hope this will work..plz dolet me know as it will be helpful for me as well..
the type char has no functions, as it's a fundamental data type. Whatyou want to do is use wrapper class's functionCharacter.getNumericValue(alpha)
getNumericValue() is a method of the Character object, not the char primitive.Primitives have no methods. So your code should beint index = Character.getNumericValue(alpha);untested, but should work.