Scanner class with char

How do i make this work?Scanner class doesnt seem to have anything to input a char from the keyboard?Do i have to turn it inot a string or something?
import java.util.Scanner;
public class Char
  public static void main(String[] args)
          char letter ;
       int count = 0 ;
       System.out.println (" Enter first character : " );
          Scanner myScanner = new Scanner (System.in);
      letter = myScanner.getChar();
       while ( letter != '!')
            System.out.println(letter);
            count++ ;
            System.out.print("Enter next  character : ") ;
            letter = myScanner.nextchar();
       System.out.println(" Number of characters was " + count);
}

Try a java.util.Pattern with the next() method.
import java.util.NoSuchElementException;
import java.util.Scanner;
class Z
    public static void main(String[] args)
        Scanner sc = new Scanner(System.in);
        String s = "";
        try
            s = sc.next(".");
        catch (NoSuchElementException e)
            System.out.println("Only single characters allowed");
        System.out.println("Valid input: " + s);
        sc.close();
}

Similar Messages

  • Help using scanner class to count chars in file

    Hi all, I am learning Java right now and ran into a problem. I need to use the Scanner class to accurately count the number of chars in a file including the line feed chars 10&13.
    This what I have and it currently reports a 201 byte file as having 194 chars:
         File file = new File(plainFile);
         Scanner inputFile = new Scanner(file);
         numberOfChars = 0;
         String line;
         //count characters in file
         while (inputFile.hasNextLine())
              line = inputFile.nextLine();
              numberOfChars += line.length();
    I know there are other ways using BufferedReader, etc but I have to use Scanner class to do this.
    Thanks in advance!

    raichle wrote:
    Wow guys, thanks for the help! I've got a RTFMWell, what's wrong to have a look at the API docs for the Scanner class?
    and directions that go against the specs I said.Is that so strange to suggest a better option? What if I ask a carpenter "how do I build a table with a my stapler?". Should I give the man an attitude if he tells me I'd better use a saw and hammer?
    I'm also aware that it "eats" those chars and obviously looking for a way around that.
    I've looked through the java docs, but as I said, I'm new to this and they're difficult to understand. The class I am auditing req's that this be done using Scanner, but I don't see why you demand an explanation.
    Can anybody give me some constructive help?Get lost?

  • Help with using Scanner Class

    Hi there - I'm a newbie to Java and may have posted this in the wrong forum previously.
    I am trying to modify a program so instead of using a BufferReader, a scanner class will be used. It is basically a program to read in a name and then display the variable in a line of text.
    Being new to Java and a weak programmer, I am getting in a mess with this and missing something somewhere. I don't think I'm using scanner in the correct way.
    Any help or pointers would be good. There are 2 programs of code being used. 'Sample' and 'Run Sample'
    Thanks in advance.
    Firstly, this program will run named 'Sample'
    <code>
    * Sample.java
    * Class description and usage here.
    * Created on 15 October 2006
    package internetics;
    * @author John
    * @version 1.2
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    // import com.ralph.*;
    public class Sample extends JFrame
    implements java.awt.event.ActionListener{
    private JButton jButton1; // this button is for pressing
    private JLabel jLabel1;
    private String name;
    /** Creates new object ChooseFile */
    public Sample() {
    initComponents();
    name = "";
    selectInput();
    public Sample(String name) {
    this();
    this.name = name;
    private void initComponents() {
    Color bright = Color.red;
    jButton1 = new JButton();
    jLabel1= new JLabel();
    addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent evt) {
    exitForm(evt);
    getContentPane().setLayout(new java.awt.GridLayout(2, 1));
    jButton1.setBackground(Color.white);
    jButton1.setFont(new Font("Verdana", 1, 12));
    jButton1.setForeground(bright);
    jButton1.setText("Click Me!");
    jButton1.addActionListener(this);
    jLabel1.setFont(new Font("Verdana", 1, 18));
    jLabel1.setText("05975575");
    jLabel1.setOpaque(true);
    getContentPane().add(jButton1);
    getContentPane().add(jLabel1);
    pack();
    public void actionPerformed(ActionEvent evt) {
    System.out.print("Talk to me " name " : ");
    try {
    jLabel1.setText(input.readLine());
    } catch (IOException ioe) {
    jLabel1.setText("Ow! You pushed my button");
    System.err.println("IO Error: " + ioe);
    /** Exit this Application */
    private void exitForm(WindowEvent evt) {
    System.exit(0);
    /** Initialise and Scan input Stream */
    private void selectInput() {
    input = new Scanner(new InputStreamReader(System.in));
    /**int i = sc.nextInt(); */
    /** Getter for name prompt */
    public String getName() {
    return name;
    /** Setter for name prompt */
    public void setName(String name) {
    this.name = name;
    * @param args the command line arguments
    public static void main(String args[]) {
    new Sample("John").show();
    </code>
    and this is the second program called 'RunSample will run.
    <code>
    class RunSample {
    public static void main(String args[]) {
    new internetics.Sample("John").show();
    </code>

    The compiler I'm using is showing errors in these areas of the code. I've read the tutorials and still can't get it. They syntax for the scanner must be in the wrong format??
    the input.readLine appears incorrect below.
      public void actionPerformed(ActionEvent evt) {
        System.out.print("Talk to me " +name+ " : ");
        try {
            jLabel1.setText(input.readLine());
        } catch (IOException ioe) {
          jLabel1.setText("Ow! You pushed my button");
          System.err.println("IO Error: " + ioe);
        }and also here...
    the input is showing errors
      /** Initialise and Scan input Stream */
      private void selectInput() {
        input = new Scanner(new InputStreamReader(System.in));
       /**int i = sc.nextInt(); */
      }Thanks

  • Problem with 1.5 Scanner class

    I'm trying to learn to use the new Scanner class in Java 1.5. I wrote this little program:
    import java.util.*;
    public class Howdy {
      public static void main(String[] args) {
        Scanner reader = Scanner.create(System.in);
        String name = reader.readLine();
        System.out.println("Hello, " + name);
    }When I try to compile it, I get these complaints:
    Howdy.java:5: cannot find symbol
    symbol  : method create(java.io.InputStream)
    location: class java.util.Scanner
        Scanner reader = Scanner.create(System.in);
                                ^
    Howdy.java:6: cannot find symbol
    symbol  : method readLine()
    location: class java.util.Scanner
        String name = reader.readLine();
                            ^
    2 errorsI know I have the 1.5 goodies turned on, because I can (for example) use the enhanced for loop.
    What's the problem?

    Can someone tell me what I'm doing wrong here.....I have a input file that has 7 rows and 10 columns. I posted the error I'm getting below. Thanks.
    import java.util.Scanner;
    import java.io.File;
    import java.io.IOException;
    public class windChill
    public static void main(String[] args) throws IOException
    File inputFile = new File("input.txt");
    Scanner fscan = new Scanner ( inputFile );
    Scanner lscan;
    lscan = new Scanner(fscan.nextLine());
    int [][] chill = new int [7][10];
    for (int i = 0;i < 7; i++)
    for (int j = 0;j < 10; j++)
    chill[i][j] = lscan.nextInt();
    lscan = new Scanner(fscan.nextLine());
    System.out.println(chill[1][9]);          
    ----jGRASP exec: java windChill
    Exception in thread "main" java.util.NoSuchElementException: No line found
         at java.util.Scanner.nextLine(Unknown Source)
         at windChill.main(windChill.java:37)
    ----jGRASP wedge2: exit code for process is 1.
    ----jGRASP: operation complete.

  • Problems with the Scanner class and the decimal point

    I'm creating a GUI so to get the user input (double value) I use a jText field and the Scanner to read that value:
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
            String time = jTextTime.getText();
           double t = new Scanner(time).nextDouble();
            String cy = Double.toString(t);
            jTextCycles.setText(cy);
        }                                  The problem is that the decimal point it's a comma so if I write:
    1.2
    t = (Error InputMismatchException)
    1.236
    t = 1236.0
    1,2
    t = 1.2
    So I try using the parse method to get the double value:
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
            String time = jTextTime.getText();
           double t = Double.parseDouble(time);
            String cy = Double.toString(t);
            jTextCycles.setText(cy);
        }                            In this case the method parseDouble() takes the dot as the decimal point so if i write:
    1.2
    t = 1.2
    1.236
    t = 1.236
    1,2
    t = (Error InputMismatchException)
    � What can I do to Scanner class to accept the dot as the decimal point?
    I think that the problem is becouse in some countries (I'm from Colombia) the decimal point is a comma and in others is the dot.
    Thanks

    From the Javadocs for Scanner:
    Localized numbers
    An instance of this class is capable of scanning numbers in the standard formats as well as in the formats of the scanner's locale. A scanner's initial locale is the value returned by the Locale.getDefault() method; it may be changed via the useLocale(java.util.Locale) method.
    If you change your locale to one of those that does use a comma for a decimal point, it should work.

  • How to use the scanner class to ask for a character?

    Hey guys, this is my assignment:
    Ask the user for a single letter and a sentence, and print out the
    number of times that letter shows up in the sentence.
    Please tell me how to scan for a character. I tried this:
    import java.util.Scanner;
    public class Frequencies
        public static final void main(String[] args)
            Scanner scanner = new Scanner(System.in);
            Scanner scan = new Scanner(System.in);
            System.out.println("Enter a sentence");
            String x = scanner.next();
            System.out.println("Enter a letter to look for");
            String y = scan.next();
            char z = y.charAt(0);
            int chara = 0;
            for(int i = 0; i<x.length(); i++){
                    if(z==y.charAt(i)){
                            chara = chara++;
            System.out.println("There are " + chara + " " + z + "s in the sentence");
    }and got the error after Running (not compiling):
    Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 1
            at java.lang.String.charAt(String.java:687)
            at Frequencies.main(Frequencies.java:16)I thought this meant that I was asking for the character in postition 1 of string y, but in my code I wrote position 0
    when I tried inserting words in the character place (just to see what happened, not expecting functionallity, I got
    Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: [NUMBER OF CHARACTERS]
            at java.lang.String.charAt(String.java:687)
            at Frequencies.main(Frequencies.java:16)Please help.
    The assignment isn't due nor graded, this is just killing me lol.
    Thanks in advance
    Edited by: Sevan on Oct 18, 2008 4:40 PM

    jverd wrote:
    Skydev2u wrote:
    I've used this method for a while now and it gets the job done.
    import java.util.Scanner;
    public class ReadInput {
    public static void main(String[] args) {
    Scanner UserInput = new Scanner(System.in);
    char letter = UserInput.findWithinHorizon(".", 0).charAt(0);
    I know you're trying to help, but this isn't really doing it. It does nothing to address the source of the OP's problem. The way he's doing it now is almost right. He just needs to do a tiny bit of detective work to fix a small bug. Tossing off a totally different approach, with no explanation, is not particularly helpful.Your right jverd I skimmed the OP's problem too quick;y and in tern didn't understand it fully. After reading the post thoroughly I saw that the problem can be solved by taking the sentence the user enters and then converting it into a array of characters. Then searching for the specific letter the user enters is achieved by comparing it to each individual element of the char array. Then incrementing a counter variable each time a match is made. I hope this example code solve your problem.
    * @author skydev
    import java.util.Scanner;
    public class SentenceReader {
        public static void main(String[] args) {
            int counter = 0; //Amount of time the letter appears in the sentence
            char letter;    //Letter the user search for
            char[] sentenceArray; //char array to hold the elements of the string the user inputs
            String sentence; //sentence the user inputs
            Scanner UserInput = new Scanner(System.in);
            System.out.println("Please enter a sentence! ");
            sentence = UserInput.nextLine();
            sentenceArray = sentence.toCharArray(); //splits up the users sentence into a array of char
            System.out.println("Please enter a letter to search for ");
            letter = UserInput.findWithinHorizon(".", 0).charAt(0);
             for(int i = 0; i < sentence.length(); i++){
                    if(letter == sentenceArray){ //search to see if the letter of interest equals to each char (letter) of the array
    counter++; //increments the amount of time the letter appears, set to 0 by default
    System.out.println("The letter appeared " + counter + " times in the sentence"); //Displays the result :) I love programming

  • Nuances of the Scanner Class

    I'm having trouble with the Scanner class... here is a snippet of code from a program I am writing.
    ==========
    1 System.out.print("Enter the name of the new passenger-> ");
    2      String passengerName = scan.nextLine();
    3      System.out.println(passengerName);
    4      
    5      System.out.print("Enter the ticket type (E or F)-> ");
    6      String desiredClassType = scan.nextLine();
    7      System.out.println(desiredClassType);
    8      char desiredClassTypeCode = (desiredClassType.toUpperCase()).charAt(0);
    9      
    10
    11      System.out.print("Enter the desired row-> ");
    12      int desiredRow = scan.nextInt();
    13      System.out.println(desiredRow);
    14      
    15      System.out.print("Enter the desired seat-> ");
    16      String desiredSeat = scan.nextLine();
    17      System.out.println(desiredSeat);
    18      char desiredSeatCode = desiredSeat.charAt(0);
    19      
    20      System.out.print("Smoking or non-smoking (S or N)-> ");
    21      String desiredSmoking = scan.nextLine();
    22      System.out.println(desiredSmoking);
    23      char desiredSmokingCode = (desiredSmoking.toUpperCase()).charAt(0);
    ==========
    The problem is, after the scan.nextInt() on line 12, the user never gets a chance to enter input for the scan.nextLine() on line 16. The program just plows right on through and returns the following error at line 18:
    Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 0
    If I change the scan.nextLine() in line 16 to scan.next(), it works alright until the next time I call a scan.nextLine at line 21. Then the same error message appears at line 23. Is there something I'm missing? I can't just change everything to scan.next because some inputs require a string that includes whitespace. However, scan.nextLine keeps giving me these errors...?

    when the program asks you to enter a number, you enter a number and press enter. The nextInt method reads the number but leaves the line feed. Next, the program calls nextLine. What will it return? It will return the 0-length string from where the number ended until the line feed, and removes the line feed from the stream. This is why the user never gets a chance to enter anything: he's already entered what the program was looking for.
    To get rid of the line feed, call nextLine directly after calling nextInt and throw away the return value.
    int desiredRow = scan.nextInt();
    scan.nextLine(); // throw away rest of line

  • Scanner class and Ready to Program

    Hi I have only been programming for about 3 years. I have always used Ready to Program as my environment and I rly like it. I used to always used the BufferedReader to read in inputs from the keyboard. now I am in university and we always use the Scanner class to read in the inputs and i have unfortunately had to conform because my narrow minded professors don't want to help me when I code my way, ughhh, but ya.
    pretty much, I believe when i have gone in the properties of Ready to Program it says it is using JDK 1.4. so I'm guessing it is styll using that version of Java or something ( I have never had to go into the propeties of java to change anything so I am not sure if there is a way to import the new version of Java or not) but basically I went to Ready's site and it said that a new Beta is out that I have to wait for them to email to recieve. http://www.holtsoft.com/ready/support/ . and the beta is version 1.6 so I am asumming that it is the one that comes packaged with 1.6. my question, as I believe it will be a while before i recieve the link, is there anyway to import and make java look at my jdk 1.6 at all. I have put them in the same folder but I don't know where to put the JDK or JRE 1.6 folders to allow Ready to read it.

    oh, and has anyone recieved the new Ready to program beta v1.6? I was wondering if I could get a copy because its taking so long ot get it, I think i applied about a week and a half ago

  • Scanner class not recognized

    A little background: I've decided to teach myself java after being given the book "Java Software Solutions" by Lewis and Loftus (fourth edition). I'm reading through it, working the examples. This is definitely a newbie question.
    I'm trying to input some text using the scanner class. I'm running java 5.0, and have no other versions of java running on the computer. When I try and compile the following code, I get the message "cannot find symbol ... symbol: method create(java .io.InputStream) ... class java.util.Scanner ..."
    Here is my code:
    import java.util.Scanner;
    public class ScannerTest {
        public static void main(String[] args){
            int a;
            Scanner scan = Scanner.create(System.in);
            System.out.println("Please enter an integer --> ");
            a = scan.nextInt();
            System.out.println("You entered " + a);My class path is set correctly, so that's not the problem. Also, I'm able to use the random class by importing java.util.Random. I've tried to import the entire util class (import java.util.*), but this won't work.
    What am I missing? Thanks in advance.

    Thanks, I have it working now. Frustrating though,
    because the code came STRAIGHT out of the book (page
    129 and throughout).Ought to tell you something about the book... :o)
    It may have been written when 1.5 was still beta - I don't know if that method was available then. It'd be prudent to check the errata online, though. Either way, glad you got it working, and good luck with your progress!

  • Scanner class refuses to work

    Hi, I am having a really big pain in the butt issue with java, (ive tried using eclipse, jgrasp and bluej, all giving me same error)
    I am trying to read from a .dat file (which can easily be opened with wordpad or notepad to reveal contents)
    I am using scanner class
    Scanner key = new Scanner (new File ("file.dat"));
    no matter what i do, i keep getting the same error message FileNotFound Exception, i have gotten java to print out the directory it is searching for, i have put the file into that directory and i am still getting nothing....ive have been at this for two days now, and it is driving me nuts, nothing is making sense and i have asked everyone i know, they say that is the code you need to use to get it to read.
    P.S i have also tried
    File abc = new File ("file.dat");
    Scanner key = new Scanner (abc); same result
    I even got a little hopeful and tried just plain old
    Scanner key = new Scanner ("file.dat); and i get nada, same error, im wondering if anyone has seen this before.

    public static void populate(){
    Scanner keyb= new Scanner(new File("city.dat"));
    for(int j=0;j<=18;j++){
         int x = keyb.nextInt();
         String abr=keyb.next();
         int h = convert(abr);
         String name=keyb.next();
         int pop=keyb.nextInt();
         int alt = keyb.nextInt();
         city[x]=new cities(name,pop,alt);
         }Error Message: Exception in thread "main" java.lang.Error: Unresolved compilation problems:
         Unhandled exception type FileNotFoundException
         Unhandled exception type FileNotFoundException
         at Main.populate(Main.java:45) Line 45 is Scanner keyb= new Scanner(new File("city.dat"));
         at Main.main(Main.java:34) Line 34 is a call to the populate method.

  • Why can't classes with private constructors be subclassed?

    Why can't classes with private constructors be subclassed?
    I know specifying a private nullary constructor means you dont want the class to be instantiated or the class is a factory or a singleton pattern. I know the workaround is to just wrap all the methods of the intended superclass, but that just seems less wizardly.
    Example:
    I really, really want to be able to subclass java.util.Arrays, like so:
    package com.tassajara.util;
    import java.util.LinkedList;
    import java.util.List;
    public class Arrays extends java.util.Arrays {
        public static List asList(boolean[] array) {
            List result = new LinkedList();
            for (int i = 0; i < array.length; i++)
                result.add(new Boolean(array));
    return result;
    public static List asList( char[] array) {
    List result = new LinkedList();
    for (int i = 0; i < array.length; i++)
    result.add(new Character(array[i]));
    return result;
    public static List asList( byte[] array) {
    List result = new LinkedList();
    for (int i = 0; i < array.length; i++)
    result.add(new Byte(array[i]));
    return result;
    public static List asList( short[] array) {
    List result = new LinkedList();
    for (int i = 0; i < array.length; i++)
    result.add(new Short(array[i]));
    return result;
    public static List asList( int[] array) {
    List result = new LinkedList();
    for (int i = 0; i < array.length; i++)
    result.add(new Integer(array[i]));
    return result;
    public static List asList( long[] array) {
    List result = new LinkedList();
    for (int i = 0; i < array.length; i++)
    result.add(new Long(array[i]));
    return result;
    public static List asList( float[] array) {
    List result = new LinkedList();
    for (int i = 0; i < array.length; i++)
    result.add(new Float(array[i]));
    return result;
    public static List asList( double[] array) {
    List result = new LinkedList();
    for (int i = 0; i < array.length; i++)
    result.add(new Double(array[i]));
    return result;
    // Now that we extend java.util.Arrays this method is not needed.
    // /**JCF already does this so just wrap their implementation
    // public static List asList(Object[] array) {
    // return java.util.Arrays.asList(array);
    public static List asList(Object object) {
    List result;
    Class type = object.getClass().getComponentType();
    if (type != null && type.isPrimitive()) {
    if (type == Boolean.TYPE)
    result = asList((boolean[])object);
    else if (type == Character.TYPE)
    result = asList(( char[])object);
    else if (type == Byte.TYPE)
    result = asList(( byte[])object);
    else if (type == Short.TYPE)
    result = asList(( short[])object);
    else if (type == Integer.TYPE)
    result = asList(( int[])object);
    else if (type == Long.TYPE)
    result = asList(( long[])object);
    else if (type == Float.TYPE)
    result = asList(( float[])object);
    else if (type == Double.TYPE)
    result = asList(( double[])object);
    } else {
    result = java.util.Arrays.asList((Object[])object);
    return result;
    I do not intend to instantiate com.tassajara.util.Arrays as all my methods are static just like java.util.Arrays. You can see where I started to wrap asList(Object[] o). I could continue and wrap all of java.util.Arrays methods, but thats annoying and much less elegant.

    Why can't classes with private constructors be
    subclassed?Because the subclass can't access the superclass constructor.
    I really, really want to be able to subclass
    java.util.Arrays, like so:Why? It only contains static methods, so why don't you just create a separate class?
    I do not intend to instantiate
    com.tassajara.util.Arrays as all my methods are static
    just like java.util.Arrays. You can see where I
    started to wrap asList(Object[] o). I could continue
    and wrap all of java.util.Arrays methods, but thats
    annoying and much less elegant.There's no need to duplicate all the methods - just call them when you want to use them.
    It really does sound like you're barking up the wrong tree here. I can see no good reason to want to subclass java.util.Arrays. Could you could explain why you want to do that? - perhaps you are misunderstanding static methods.
    Precisely as you said, if they didn't want me to
    subclass it they would have declared it final.Classes with no non-private constructors are implicitly final.
    But they didn't. There has to be a way for an API
    developer to indicate that a class is merely not to be
    instantiated, and not both uninstantiable and
    unextendable.There is - declare it abstract. Since that isn't what was done here, I would assume the writers don't want you to be able to subclass java.util.Arrays

  • How do I write an external class with global constants?

    Hi you all !
    First I want to explain what exactly I want to do:
    I have an application that should run in different resolutions. The app runs fullscreen, and I don't use Layouts or something, just a single Frame with a Graphics Object.
    Now to handle the different resolutions, I want to write an external class with some constants to use. The usage in my main Class should be something like this:
    public
    class blah
    private Constants myConstants;
    public blah()
    if (highResolution)
    myConstants = new hiResConstants();
    else
    myConstants = new loResConstants();
    System.println(String.valueOf(myConstants.SCREEN_WIDTH);
    }or somthing like that. The important fact is that I can choose the constants at runtime and that I am NOT forced to use methods to get the values, cause something like
    System.println(String.valueOf(myConstants.getScreenWidth());sux if you have methods using 5 or more parameters.
    Anybody out there who understood my problem and can help me??? PLEASE?
    best regards,
    Skippy

    First, what's so much worse about
    System.println(myConstants.getScreenWidth());
    than
    System.println(myConstants.ScreenWidth);
    Is the extra five characters really that bad? (Note
    you don't need the String.valueOf method call.)Well actually it was a wrong example I gave here, but it's not the call that makes me shake but the implementation:
    public int screenWidth = 1024;vs.
    public
    int getScreenWidth()
    return 1024;
    }Here it makes a bigger difference, even when you think of managing about 100 or even more constants.
    Second, why do you have methods that take five or more
    parameters!?Well, maybe this example show up what I mean:
    if (cursorIsInArea(100,100,200,200,areaId))
    doSomeStuff();Ok, I could use Rectangles here, but if you think of the timing here (I draw 30 frames / sec and this check comes about every frame or the animation would be choppy) I refuse to create an Object everytime I make this call.
    Btw: Is it worth thinking about the time of execution like I did in this example? OO is a neat thing, but is it that fast?
    I don't think isCursorInArea(new Rectangle(100,100,200,200),areaId) is such a great idea, but I might be wrong.
    It sounds like you're trying to compound a bad design
    with an even worse design for no good reason!Well, I'm not that experienced Java programmer to judge about that, but I (and my profs at university too) found my codes well structured and designed so far.
    Skippy
    PS: the string.valueOf(123) call came from cut&paste:
    system.out.println(string.valueOf(number1)+string.valueOf(number2));Try this without the function.... ;-)

  • Enhance standard class with event handler method

    In trying to enhance a standard class with a new event handler class, I find that the ECC 6.0 EHP4 system does not appear to recognise the fact the method is an event handler method.  The specific example is a new method to handle the event CL_GUI_ALV_GRID->USER_COMMAND. 
    I notice that the flag called Active has not been ticked - see image below.  Perhaps this is the reason why the event handler is not being triggered.
    Note that there is an event handler for the same event in the standard class which obviously is executed as expected.  Any ideas on limitations in the system or I am missing a step?
    Thanks
    John

    Thank you for your replies.
    There is a bug in the ALV handler of a standard SAP class (when executed in ITS WebGUI) and I was hoping to create a custom event handler as an Enhancement to execute some custom code to sort of "handle the bug". 
    I agree - ideally it should be done in a Z class but that will not give me access to the object methods and attributes of the enhanced class.
    Cheers,
    John

  • Help using scanner.class someone help me

    ive been working on some code and the thing is i am stuck on how do i count the number of intergers between 1 and 5. for example lets say i inputted using a scanner.class 1,2,2,3,3,3 i want my program to then say how many 2's I have entered and and how many 3's i have entered. So basically if using a scanner.class (keyboard class) in java instead of hardwiring the numbers into an array how do i count out the number of intergers and display them in my output

    hardwiring the numbers into an array how do i count
    out the number of intergers and display them in my
    outputTry this.
            Scanner sc = new Scanner(System.in);
            System.out.println("Enter numbers:");
            int i = 0;
            int count = 0;
            Map <Integer, Integer> intMap = new TreeMap <Integer, Integer>();
            while( true ) {
                i = sc.nextInt();
                if(i < 0 || i > 5) break;
                // Code to count the numbers entered.
                if(intMap.containsKey(new Integer(i))) {
                    count = intMap.get(new Integer(i)).intValue();
                    count++;
                } else {
                    count = 1;
                intMap.put(new Integer(i), new Integer(count));
            System.out.println(intMap);At forum users: Pardon me for all my variable names and poor coding style and lack of comments and...

  • Need driver for canon mg 5250 as scanner is not working with version 10.7. Can you please help me to find the driver so scanner works with WIFI?

    need driver for canon mg 5250 as scanner is not working with version 10.7. Lion. Can you please help me to find the driver so scanner works with WIFI?

    Try with the latest Apple driver package for Canon (released 15th Feb):
    http://support.apple.com/kb/DL899
    This solved my problem with the printing.

Maybe you are looking for

  • How do I move from a dead computer to a new computer?

    Reading 20 pages or more and I can't sort this out. It should be EASY! Every instruction I see talks about moving a BACKED UP profile to overwrite the new profile. My old profiles are NOT in backed up format. The old computer dddd-died... before I co

  • Went to France, updated while there, now itunes stuck in French! how do I fix this?

    Visited France. Updated while there. Now back and iTunes store, and updates still in French. Do not know how to switch.

  • CSS or Java Script to top left align a web magazine?

    We have created an online magazine with InDesign and exported it as an HTML file. The problem is it default centers and I would like it to align to the top left of the screen. The only way I see to do this right now is to add a CSS or Java script whe

  • Sync facebook to iphone

    Just a stupid user question.  When I got my iPhone, I was able to sync contacts, via facebook and gmail...but I forgot where to do this. 

  • ACR6 and LR2 in anticipation of LR3

    Just a quick question. Does this workflow work? Edit levels, etc of an image in ACR6.0 In LR2.7, click on the arrow in the top right-hand corner of the image to import settings from the xmp file that ACR updated Then, in LR, edit metadata and export.