-1

I am storing the zero value at specific date.
I am getting the exception at dur_call.put(value, "0")

HashMap<String, String> dur_call = new HashMap<String, String>();
HashMap<String, String> brows_call = new HashMap<String, String>();
HashMap<String, String> brows_call_dst = new HashMap<String, String>();
HashMap<String, String> subs = new HashMap<String, String>();
HashMap<String, String> sub_dur = new HashMap<String, String>();
HashMap<String, String> act = new HashMap<String, String>();
HashMap<String, String> low_bal = new HashMap<String, String>();
HashMap<String, String> deact = new HashMap<String, String>();
HashMap<String, String> re_act = new HashMap<String, String>();

for (String value : datetime) {
    dur_call.put(value, "0");
    brows_call.put(value, "0");
    brows_call_dst.put(value, "0");
    subs.put(value, "0");
    sub_dur.put(value, "0");
    act.put(value, "0");
    low_bal.put(value, "0");
    deact.put(value, "0");
    re_act.put(value, "0");
}
Pshemo
  • 122,468
  • 25
  • 185
  • 269
  • 1
    Woah, that looks scary! Use [help] on more information about posting a question. – Abubakkar May 04 '17 at 10:47
  • 1
    Please consider revising the code sample you posted in this question. As it currently stands, its formatting and scope make it hard for us to help you; here is a [great resource](http://stackoverflow.com/help/mcve) to get you started on that. And showing us what `datetime` is would also help a lot, since one of its elements is apparently not a String – Robin Topper May 04 '17 at 10:50
  • Are you sure the error is one the `dur_call.put(value, "0");` line? I don't think it is. – Steve Smith May 04 '17 at 10:57

1 Answers1

0

I am sure that you get the error one line above, at

for (String value : datetime) {

That is the only place, where something wants to be converted into a String.

What is the type of variable datetime ? It seems to me that datetime is not an Iterable of Strings, which it should be (for that code to work).

Is your error an exception at runtime or a compiler error?

If it is an exception and datetime is an iterable of Strings, then you mixed up generics with some untyped Collection access - your compiler will probably give you a warning, where this occurs in your code - or you have annotated that place with a @SuppressWarnings("unchecked")

(See also What is SuppressWarnings (“unchecked”) in Java?)

In this case try to make your whole code working without the unchecked warning and without the suppression of it.

If your error is a compiler error, you need to change the key of all your Maps to the type of the datetime iterable. java.util.Date maybe?

Community
  • 1
  • 1
cyberbrain
  • 3,433
  • 1
  • 12
  • 22