开发者

Java for each issue

开发者 https://www.devze.com 2023-04-02 03:12 出处:网络
Actually I was searching for an example or similar question in Stackoverflow and I find this one : Java Objective-C for each issue. So 开发者_如何学Gothat\'s why I\'ll give the code which Android-Droi

Actually I was searching for an example or similar question in Stackoverflow and I find this one : Java Objective-C for each issue. So 开发者_如何学Gothat's why I'll give the code which Android-Droid is using in his example.The thing that I need to do is similar to the Objective C code that he is using :

StPacketInjectQueryPackage qType = (StPacketInjectQueryPackage)[[q objectForKey:@"type"] intValue]; .

According to his code...my question is how can I do that...using his Java code?

EDIT (My Problem):

If I use his code, how can I get the objectForKey:@"type" in Java.I guess it has to be similar to this :

        RPCPacketInjectQueryPackage qType = (RPCPacketInjectQueryPackage) b.getKeys  

OR b.get("type"); or something like that...

Any suggestions?


For-each in Java is pretty well documented in the standard Java documentation. For example: http://download.oracle.com/javase/1,5.0/docs/guide/language/foreach.html

If that doesn't adequately explain how to do what you're trying to do, I would suggest taking a stab at it in Java and then asking a question on StackOverflow about what is wrong with your code if you can't get it to work.


The closest thing in Java is a new (1.5 or 1.6) "enhanced" for loop.

  Iterable<Element> list = ....
  for (Element el : list) {
      System.out.println(el);
  }
0

精彩评论

暂无评论...
验证码 换一张
取 消