Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

files  RSS feed

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to convert a bytearray into a single integer.
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can't.
 
Janaranjani K
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks okay ,then how can i convert a String object into a int
 
Ranch Hand
Posts: 1704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Ranjani Kannan:
thanks okay ,then how can i convert a String object into a int



Use Integer.parseInt(String s) method. If the string does not contain a parsable integer it will throw NumberFormatException.
 
Java Cowboy
Sheriff
Posts: 16083
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to convert a bytearray into a single integer.

That depends on what you want exactly. Is it a byte array of arbitrary length? If I give you a concrete example, can you tell me what integer value you would expect? Here it is:
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ranjani Kannan: How to convert a bytearray into a single integer.


Ram Hebbale Hiriyanna: you can't


This is not entirely true. As Jesper implies, we need more details to understand what you want to do. You can easily use a byte array to represent a single number. The question is what representation are you using? Perhaps Ram meant there is not a method in the Java API to do this. You will need to define what the byte array represents in order to answer this question meaningfully.

Layne
 
PI day is 3.14 (march 14th) and is also einstein's birthday. And this is merely a tiny ad:
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!