answersLogoWhite

0


Best Answer

A String is essentially a character array with advanced functionality. Any character from a String object can be accessed by calling String's charAt(int position) method. This will return the character value at that position in the String, which can be stored within an int for ASCII value comparison.

Example:

String a = "Apple";

String b = "Banana";

int x = a.charAt(0);

int y = b.charAt(0);

boolean c = x<y; //A<B

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How can you scan a letter from a String and store it as an integer so that you can compare ASCII values?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How can you check if a variable is a string or an integer in PHP?

Integers - The "is_int()" function can be used to check if a variable is has an integer for its value. ---- is_int($variable); // Returns true if $variable is an integer - otherwise false ---- Numeric Strings - Numeric strings are strings with numbers (or things that count as numbers) in them. Numeric-string variables are not integer variables. Numeric-string variables are passed on through forms, instead of integer variables - if you were wondering. Check form values using string formats, and not integer formats. The "is_numeric()" function can be used to check if a variable is a string with numbers - and only numbers - in it (except things that add up to be numbers). ---- is_numeric($variable); // Returns true if $variable is a string, and only contains numbers (broadly speaking) - false otherwise ---- Strings - String values are just text, basically. String variables can contain integers, but that does not make it an integer-type variable - it makes it a numeric string variable. The "is_string" function can be used to check if a variable contains the value of a string. ---- is_string($variable); // Returns true if $variable is a string - false otherwise


Why using parseInt in java?

parseInt is a method in the Integer class in java and is used to parse string values into integer numbers. ex: int i = Integer.parseInt("10"); After the above line of code, the variable i will be assigned a value of 10 which is the numeric value of the string passed as argument to the parseInt method


How do you write a Java code to find number of duplicate words in a sentence?

As mentioned by others use String::split(), followed by some map (hashmap or linkedhashmap) and then merge your result. For completeness sake putting the code. import java.util.*; public class Genric&lt;E&gt; { public static void main(String[] args) { Map&lt;String, Integer&gt; unique = new LinkedHashMap&lt;String, Integer&gt;(); for (String string : "House, House, House, Dog, Dog, Dog, Dog".split(", ")) { if(unique.get(string) == null) unique.put(string, 1); else unique.put(string, unique.get(string) + 1); } String uniqueString = join(unique.keySet(), ", "); List&lt;Integer&gt; value = new ArrayList&lt;Integer&gt;(unique.values()); System.out.println("Output = " + uniqueString); System.out.println("Values = " + value); } public static String join(Collection&lt;String&gt; s, String delimiter) { StringBuffer buffer = new StringBuffer(); Iterator&lt;String&gt; iter = s.iterator(); while (iter.hasNext()) { buffer.append(iter.next()); if (iter.hasNext()) { buffer.append(delimiter); } } return buffer.toString(); } }


What is the benefit of using biased representation for the exponent portion of a floatingpoint number?

It allows you to compare two floating point values using integer hardware.


What is parse Int?

parseInt() is a method in the Integer class in Java that is used for parsing string values as numbers. int i = Integer.parseInt("10"); would result in i being assigned a value of 10


A quantity that can be equal to any integer and can take any different integer values is known as?

Integer variables


Does the volume of the string affect your buoyancy values?

no


If the domain of f(x)-x2 is integer values of x such that -3-x?

5


Can you store unlimited value in any integer type of variables?

No. In Java, you can store a limited range of values in an integer. Specifically, integers are 32-bit signed values which can store values in the range [-231, 231-1]. If you need to store more values, consider using a long integer [-263, 263-1] or the BigInteger class (which can store arbitrary-precision values).


What can i do with percentages?

You can compare two values.


A random variable is said to be discrete if?

It can take only a finite number of values. These need not be integer values.


When is the sum of a positive integer and a negative integer zero?

When the absolute value of the positive integer is the same as the absolute value of the negative one.