What is wrong with this class? Please help

I'm trying to sort a dynamically created JComboBox into Alphabetical order. However, the class below is the result of my coding and there is a problem. the code can sort only two(2) item in the JComboBox and no more which is wrong. I do not know where i'm going wrong in the selectionSort(JComboBox cmb) method. the getLargest(JComboBox cmb) method works perfectly because i have tried it. Can somebody please take a look at my codes and help me modify it.
Thanks
James
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class SortCombo extends JFrame implements ActionListener{
JButton btnAdd, btnSort;
JComboBox cmbItems;
JTextField text1;
public SortCombo(){
super("Sorting Demo");
this.getContentPane().setLayout(new GridLayout(4,1));
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
btnAdd = new JButton("Add Item to Combo Box");
btnSort = new JButton("Sort Items in ComboBox");
text1 = new JTextField(20);
cmbItems = new JComboBox();
btnAdd.addActionListener(this);
btnSort.addActionListener(this);
this.getContentPane().add(cmbItems);
this.getContentPane().add(text1);
this.getContentPane().add(btnAdd);
this.getContentPane().add(btnSort);
this.pack();
this.show();
public void actionPerformed(ActionEvent e){
if(e.getSource() == btnAdd){
String s = text1.getText();
if (!s.equals("") && !isDuplicate(s,cmbItems))
cmbItems.addItem(text1.getText());
}else if(e.getSource() == btnSort){
selectionSort(cmbItems);
// int i = getLargest(cmbItems);
// System.out.println(i);
public boolean isDuplicate(String stationName, JComboBox cmb){
int j = cmb.getItemCount();
boolean result = false;
for (int i = 0; i < j; i++){
String s = (String)cmb.getItemAt(i);
if (stationName.trim().equalsIgnoreCase(s.trim()))
result = true;
return result;
public int getLargest(JComboBox cmb){
int indexSoFar = 0;
int size = cmb.getItemCount();
for(int currIndex = 1; currIndex < size; currIndex++){
String strSoFar = (String)cmb.getItemAt(indexSoFar);
String currStr = (String)cmb.getItemAt(currIndex);
char charSoFar = strSoFar.charAt(0); charSoFar = Character.toUpperCase(charSoFar);
char currChar = currStr.charAt(0); currChar = Character.toUpperCase(currChar);
if(currChar > charSoFar){
indexSoFar = currIndex;
return indexSoFar;
public void selectionSort(JComboBox cmb){
int n = cmb.getItemCount();
for (int last = n-1; last >=1; last--){
int largest = getLargest(cmb);
String temp = (String)cmb.getItemAt(largest);
String temp2 = (String)cmb.getItemAt(last);
cmb.removeItemAt(largest);
cmb.insertItemAt(temp2,largest);
cmb.removeItemAt(last);
cmb.insertItemAt(temp,last);
public static void main(String[] args){
new SortCombo();
}

I beleive what is wrong is that your getLargest method returns the largest to your selection sort.The selectionSort places the largest at the end.On the next iteration it finds the largest again. this time at the end where you put it.Now it just does the same thing over again placing the same item at the end until the loop runs out.What you are left with is only one item it the right spot(sometimes 2).I could not get it to work the way you had it here so I tried a rewrite.It seems to work ok but it won't sort two words that start with the same letter properly.You may have to insert an algorithm to fix this.I got rid of the getLargest method and did everything in the selectionSort method.I used what I think is called a bubble sort but I'm not sure.
I hope this is what you were looking for:)
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class SortCombo extends JFrame implements ActionListener{
     JButton btnAdd, btnSort;
     JComboBox cmbItems;
     JTextField text1;
     public SortCombo(){
          super("Sorting Demo");
          getContentPane().setLayout(new GridLayout(4,1));
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          btnAdd = new JButton("Add Item to Combo Box");
          btnSort = new JButton("Sort Items in ComboBox");
          text1 = new JTextField(20);
          cmbItems = new JComboBox();
          btnAdd.addActionListener(this);
          btnSort.addActionListener(this);
          Container pane = getContentPane();
          pane.add(cmbItems);
          pane.add(text1);
          pane.add(btnAdd);
          pane.add(btnSort);
          pack();
          show();
     public void actionPerformed(ActionEvent e){
          if(e.getSource() == btnAdd){
          String s = text1.getText();
          if (!s.equals("") && !isDuplicate(s,cmbItems))
          cmbItems.addItem(text1.getText());
          }else if(e.getSource() == btnSort){
          selectionSort(cmbItems);
     public boolean isDuplicate(String stationName, JComboBox cmb){
          int j = cmb.getItemCount();
          boolean result = false;
          for (int i = 0; i < j; i++){
               String s = (String)cmb.getItemAt(i);
               if (stationName.trim().equalsIgnoreCase(s.trim()))
               result = true;
          return result;
     public void selectionSort(JComboBox cmb){
          int count = cmb.getItemCount();
          for(int start = 0;start < count;start++){
               for(int x = start;x < count-1;x++){
                    String first = (String)cmb.getItemAt(start);
                    String next = (String)cmb.getItemAt(x+1);
                    char charFirst = first.charAt(0);
                           charFirst = Character.toUpperCase(charFirst);
                    char charNext = next.charAt(0);
                    charNext = Character.toUpperCase(charNext);
                         if(charFirst > charNext){
                              String temp  = (String)cmb.getItemAt(start);
                              String temp2 = (String)cmb.getItemAt(x+1);
                              cmb.removeItemAt(start);
                              cmb.insertItemAt(temp2,start);
                              cmb.removeItemAt(x+1);
                              cmb.insertItemAt(temp,x+1);
     public static void main(String[] args){
          new SortCombo();
}p.s.(I removed the "this" references from your constructor when I rewrote it because they are implied anyway)
[email protected]

Similar Messages

  • What am i doing wrong with this class please help

    What am i doing wrong with this class? I'm trying to create a JFrame with a JTextArea and a ScrollPane so that text can be inserted into the text area. however evertime i run the program i cannot see the textarea but only the scrollpane. please help.
    import java.io.*;
    import java.util.*;
    import java.awt.event.*;
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class Instructions extends JFrame{
    public JTextArea textArea;
    private String s;
    private JScrollPane scrollPane;
    public Instructions(){
    super();
    textArea = new JTextArea();
    s = "Select a station and then\nadd\n";
    textArea.append(s);
    textArea.setEditable(true);
    scrollPane = new JScrollPane(textArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    this.getContentPane().add(textArea);
    this.getContentPane().add(scrollPane);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.setTitle("Instructions");
    this.setSize(400,400);
    this.setVisible(true);
    }//end constructor
    public static void main(String args[]){
    new Instructions();
    }//end class

    I'm just winging this so it might be wrong:
    import java.io.*;
    import java.util.*;
    import java.awt.event.*;
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class Instructions extends JFrame{
    public JTextArea textArea;
    private String s;
    private JScrollPane scrollPane;
    public Instructions(){
    super();
    textArea = new JTextArea();
    s = "Select a station and then\nadd\n";
    textArea.append(s);
    textArea.setEditable(true);
    scrollPane = new JScrollPane(textArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    // Here you already have textArea in scrollPane so no need to put it in
    // content pane, just put scrollPane in ContentPane.
    // think of it as containers within containers
    // when you try to put them both in at ContentPane level it will use
    // it's layout manager to put them in there side by side or something
    // so just leave this out this.getContentPane().add(textArea);
    this.getContentPane().add(scrollPane);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.setTitle("Instructions");
    this.setSize(400,400);
    this.setVisible(true);
    }//end constructor
    public static void main(String args[]){
    new Instructions();
    }//end class

  • What is wrong with this? pls help!

    I have this as a listener for a JButton:
         public void actionPerformed(ActionEvent e){
              try{
                   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                   String url = "jdbc:odbc:RezSystem";
                   Connection con = DriverManager.getConnection(url, "user10", "");
                   PreparedStatement stmt = con.prepareStatement("select cPassword from RezShopper where cShopperID = ?");
                   stmt.setString(1, textSignInName.getText());
                   ResultSet res = stmt.executeQuery();
                   if(res.next()){
                        String tp = String.valueOf(passPassword.getPassword());
                        String dp = res.getString(1);
                        System.out.println("text field = " + tp);
                        System.out.println("database = " + dp);
                        if (dp.equals((String)dp)){
                             System.out.println("Password accepted");
                        else{
                             System.out.println("Invalid password");
                   else{
                        System.out.println("Invalid sign in name");
              catch(Exception ex){
                   System.out.println(ex);
         }this is used to compare the value in a password field and a value in a column in an sql data base with a char data type and should check if they are the same. The problem is that even if they are the same it still prints out "Invalid password". What went wrong???
    thanks

    dp.equals(dp) should give you true, but I guess you meant dp.equals(tp). To debug it, I would print the character values of both strings. You don't need to cast the String to a String before you call equals..
    for (int x = 0; x < dp.length(); x++)
      System.out.println("dp("+x+")="+(int)dp.charAt(x));
    for (int x = 0; x < tp.length(); x++)
      System.out.println("tp("+x+")="+(int)tp.charAt(x));I assume that getPassword returns a char array and not a byte array. If it returns a byte array, it is possible that the charset encoding gives you a different string than you expected.

  • What is wrong with this class?

    It would not reconize the drawImage function
    I had another similar and it worked, what's with this.
    import java.awt.*;
    import java.applet.*;
    public class PicturePrinter {
         public void init(){
         public void paint(Graphics g,Image image,int x,int y){
              g.drawImage(image,x,y,this);
    }this one works:
    import java.awt.*;
    public class Printer {
         public void init(){
         public void paint(Graphics g,String string,int x,int y){
              g.drawString(string,x,y);
    }

    If you read
    [url=http://java.sun.com/j2se/1.5.0/docs/api/java/awt/
    Graphics.html]the relevant documentation, youwill see that there is a particular requirement for
    the fourth argument for drawImage that you are
    not fulfilling.
    Hes making it null.

  • What's wrong with this query--need help

    Requirement: need to get the names of employees who were hired on tuesday this has to use to_char function
    select ename
    from emp
    where to_char(hiredate,'day')='tuesday';
    when i execute the query
    o/p is no rows selected
    please help.
    thanks in advance.

    Hi,
    861173 wrote:
    Requirement: need to get the names of employees who were hired on tuesday this has to use to_char function
    select ename
    from emp
    where to_char(hiredate,'day')='tuesday';
    when i execute the query
    o/p is no rows selected Try:
    WHERE   TO_CHAR (hiredate, 'fmday')  = 'tuesday'Without 'FM" in the 2nd argument, TO_CHAR pads the results to make it a consistent length. If your NLS_DATE_LANGUAGE=ENGLISH, that means it will always return a 9-character string, since the longest name in English ('Wednesday') has 9 letters. 'FM' (case-insernsitive) tells TO_CHAR not to add that kind of padding.

  • What is wrong with this api Pls help

    I am creating api to migrate jobs from an extenal table to hr but when executing the script it only inserts the first record and gives this message
    "-20001 ORA-20001: The job you have entered already exists in this Business Group. Please enter a unique name for your job."
    as I mentioned the job which he means already created is the first row of the table
    here is the code
    DECLARE
    l_count Number :=0;
    v_business_group_id Number :=101;
    v_date_from date := TO_DATE('01-01-1900','DD-MM-YYYY');
    v_job_group_id number := 21;
    v_object_version_number number :=1;
    v_segment1 varchar2(10);
    v_segment2 varchar2(150);
    v_attribute2 varchar2(150);
    v_attribute3 varchar2(100);
    v_attribute4 varchar2(50);
    v_attribute5 varchar2(50);
    v_attribute6 varchar2(50);
    cursor job is select DESGN_CODE,
         DESGN_DESP_M_A,
         DESGN_DESP_F_A,
         DESGN_DESP_E ,
         DESGN_TYPE ,
         DESGN_CAT_CODE,
         GRP_CODE
    from aa_tdesignation
    Where rownum < 10
    and desgn_desp_e is not null;
    v_segment5 varchar2(100) := NULL;
    v_segment6 varchar2(100) := NULL;
    v_job_id number;
    v_job_definition_id number;
    v_name varchar2(100);
    begin
    dbms_output.put_line('##########################################################');
    dbms_output.put_line('Data Migration Of Jobs:');
    dbms_output.put_line('##########################################################');
    dbms_output.put_line('Start Time : ' || TO_CHAR(SYSDATE,'DD-MON-YYYY HH24:MI:SS'));
    for my_cur in job
    LOOP
    BEGIN
    v_segment1 := my_cur.DESGN_CODE;
    v_segment2 := my_cur.DESGN_DESP_M_A;
    v_attribute2 := my_cur.DESGN_DESP_F_A;
    v_attribute3 := my_cur.DESGN_DESP_E;
    v_attribute4 := my_cur.DESGN_TYPE;
    v_attribute5 := my_cur.DESGN_CAT_CODE;
    v_attribute6 := my_cur.GRP_CODE;
    HR_JOB_API.CREATE_JOB
    (p_business_group_id => v_business_group_id
    ,p_date_from => v_date_from
    ,p_job_group_id => v_job_group_id
    ,p_object_version_number => v_object_version_number
    ,p_segment1 => v_segment1
    ,p_segment2 => v_segment2
    ,p_segment5 => v_segment5
    ,p_segment6 => v_segment6
    ,p_attribute2 => v_attribute2
    ,p_attribute3 => v_attribute3
    ,p_attribute4 => v_attribute4
    ,p_attribute5 => v_attribute5
    ,p_attribute6 => v_attribute6
    ,p_job_id => v_job_id
    ,p_job_definition_id => v_job_definition_id
    ,p_name => v_name);
    Dbms_output.put_line('Sucess'||' '||my_cur.DESGN_CODE||' '||my_cur.DESGN_DESP_M_A);
    L_COUNT:=L_COUNT+1;
    END;
    END LOOP;
    DBMS_OUTPUT.PUT_LINE ('Total Nubmer of record'||L_COUNT);
    Exception
    When others then
    dbms_output.put_line(sqlcode||' '||sqlerrm);
    DBMS_OUTPUT.PUT_LINE ('Total Nubmer of record'||L_COUNT);
    end;
    Thanks

    You've got to remove either the semicolon or the slash at the end of the script as both will execute it, so the second time with the same info it fails.

  • I can't open any program anymore an my ipod since the last 30 minutes, no more games and social network programs. What is wrong with my ipod.Please help

    I can't open any program anymore on my ipod since the last 30 minutes, please help

    Did you try to reset the device by holding the sleep and home button until the Apple logo come back again?
    If this does not work, set it up again "as new device", shown in this article: How to set up your iPhone or iPod touch as a new device

  • What's wrong with this?HELP

    What's wrong with this piece of code:
    clickhereButton.addActionListener(this);
         ^
    That's my button's name.
    Everytime I try to complie the .java file with this code in it it says:
    Identifier expected: clickhereButton.addActionListener(this);
    ^
    Please help.

    You must have that code in a method or an initilizer block... try moving it to eg. the constructor.

  • FileFilter????What's wrong with this code???HELP!!

    I want to limit the JFileChooser to display only txt and java file. But the code I wrote has error and I don't know what's wrong with it. can anyone help me to check it out? Thank you.
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class FileFilterTest extends JPanel
         public static void main(String[] args)
              new FileFilterTest();
         public class fFilter implements FileFilter
              public boolean accept(File file)
                   String name = file.getName();
                   if(name.toLowerCase().endsWith(".java") || name.toLowerCase().endsWith(".txt"))
                        return true;
                   else
                        return false;
         public FileFilterTest()
              JFileChooser fc = new JFileChooser();
              fc.setFileFilter(new fFilter());
              fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
              fc.setCurrentDirectory(new File(System.getProperty("user.dir")));
              //fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
              //fc.setMultiSelectionEnabled(true);
              int returnVal = fc.showDialog(FileFilterTest.this, "Open File");
              if(returnVal == JFileChooser.APPROVE_OPTION)
                   String file = fc.getSelectedFile().getPath();
                   if(file == null)
                        return;
              else if(returnVal == JFileChooser.CANCEL_OPTION)
                   System.exit(0);
              else
                   System.exit(0);
              JFrame f = new JFrame();
              FileFilterTest ff = new FileFilterTest();
              f.setTitle("FileFilterTest");
              f.setBackground(Color.lightGray);
              f.getContentPane().add(ff, BorderLayout.CENTER);
              f.setSize(800, 500);
              f.setVisible(true);
    }

    There are two file filters
    class javax.swing.filechooser.FileFilter
    interface java.io.FileFilter
    In Swing you need to make a class which extends the first one and implements the second. Sometimes you may not need to implement the second, but it is more versitle to do so and requires no extra work.

  • HT201209 I'm new to this an yesterday I bought 65$ worth of iTunes music using a iTunes gift card. Then I got these emails saying I am being billed again????? What do I do???? I'm very frustrated with this. Please help me

    yesterday I bought 65$ worth of iTunes music using a iTunes gift card. Then I got these emails saying I am being billed again????? What do I do???? I'm very frustrated with this. Please help me

    What e-mail are you talking about?
    What exactly did it say?
    Are you sure that the e-mail was not your receipt?

  • Can someone tell me what's wrong with this LOV query please?

    This query works fine..
    select FILTER_NAME display_value, FILTER_ID return_value
    from OTMGUI_FILTER where username = 'ADAM'
    But this one..
    select FILTER_NAME display_value, FILTER_ID return_value
    from OTMGUI_FILTER where username = apex_application.g_user
    Gives the following error.
    1 error has occurred
    * LOV query is invalid, a display and a return value are needed, the column names need to be different. If your query contains an in-line query, the first FROM clause in the SQL statement must not belong to the in-line query.
    Thanks very much,
    -Adam vonNieda

    Ya know, I still don't know what's wrong with this.
    declare
    l_val varchar2(100) := nvl(apex_application.g_user,'ADAM');
    begin
    return 'select filter_name display_value, filter_id return_value
    from otmgui_filter where username = '''|| l_val || '''';
    end;
    Gets the same error as above. All I'm trying to do is create a dropdown LOV which selects based on the apex_application.g_user.
    What am I missing here?
    Thanks,
    -Adam

  • What's wrong with this simple code?

    What's wrong with this simple code? Complier points out that
    1. a '{' is expected at line6;
    2. Statement expected at the line which PI is declared;
    3. Type expected at "System.out.println("Demostrating PI");"
    However, I can't figure out them. Please help. Thanks.
    Here is the code:
    import java.util.*;
    public class DebugTwo3
    // This class demonstrates some math methods
    public static void main(String args[])
              public static final double PI = 3.14159;
              double radius = 2.00;
              double area;
              double roundArea;
              System.out.println("Demonstrating PI");
              area = PI * radius * radius;
              System.out.println("area is " + area);
              roundArea = Math.round(area);
              System.out.println("Rounded area is " + roundArea);

    Change your code to this:
    import java.util.*;
    public class DebugTwo3
         public static final double PI = 3.14159;
         public static void main(String args[])
              double radius = 2.00;
              double area;
              double roundArea;
              System.out.println("Demonstrating PI");
              area = PI * radius * radius;
              System.out.println("area is " + area);
              roundArea = Math.round(area);
              System.out.println("Rounded area is " + roundArea);
    Klint

  • I can't figure out what's wrong with this code

    First i want this program to allow me to enter a number with the EasyReader class and depending on the number entered it will show that specific line of this peom:
    One two buckle your shoe
    Three four shut the door
    Five six pick up sticks
    Seven eight lay them straight
    Nine ten this is the end.
    The error message i got was an illegal start of expression. I can't figure out why it is giving me this error because i have if (n = 1) || (n = 2) statements. My code is:
    public class PoemSeventeen
    public static void main(String[] args)
    EasyReader console = new EasyReader();
    System.out.println("Enter a number for the poem (0 to quit): ");
    int n = console.readInt();
    if (n = 1) || (n = 2)
    System.out.println("One, two, buckle your shoe");
    else if (n = 3) || (n = 4)
    System.out.println("Three, four, shut the door");
    else if (n = 5) || (n = 6)
    System.out.println("Five, six, pick up sticks");
    else if (n = 7) || (n = 8)
    System.out.println("Seven, eight, lay them straight");
    else if (n = 9) || (n = 10)
    System.out.println("Nine, ten, this is the end");
    else if (n = 0)
    System.out.println("You may exit now");
    else
    System.out.println("Put in a number between 0 and 10");
    I messed around with a few other thing because i had some weird errors before but now i have narrowed it down to just this 1 error.
    The EasyReader class code:
    // package com.skylit.io;
    import java.io.*;
    * @author Gary Litvin
    * @version 1.2, 5/30/02
    * Written as part of
    * <i>Java Methods: An Introduction to Object-Oriented Programming</i>
    * (Skylight Publishing 2001, ISBN 0-9654853-7-4)
    * and
    * <i>Java Methods AB: Data Structures</i>
    * (Skylight Publishing 2003, ISBN 0-9654853-1-5)
    * EasyReader provides simple methods for reading the console and
    * for opening and reading text files. All exceptions are handled
    * inside the class and are hidden from the user.
    * <xmp>
    * Example:
    * =======
    * EasyReader console = new EasyReader();
    * System.out.print("Enter input file name: ");
    * String fileName = console.readLine();
    * EasyReader inFile = new EasyReader(fileName);
    * if (inFile.bad())
    * System.err.println("Can't open " + fileName);
    * System.exit(1);
    * String firstLine = inFile.readLine();
    * if (!inFile.eof()) // or: if (firstLine != null)
    * System.out.println("The first line is : " + firstLine);
    * System.out.print("Enter the maximum number of integers to read: ");
    * int maxCount = console.readInt();
    * int k, count = 0;
    * while (count < maxCount && !inFile.eof())
    * k = inFile.readInt();
    * if (!inFile.eof())
    * // process or store this number
    * count++;
    * inFile.close(); // optional
    * System.out.println(count + " numbers read");
    * </xmp>
    public class EasyReader
    protected String myFileName;
    protected BufferedReader myInFile;
    protected int myErrorFlags = 0;
    protected static final int OPENERROR = 0x0001;
    protected static final int CLOSEERROR = 0x0002;
    protected static final int READERROR = 0x0004;
    protected static final int EOF = 0x0100;
    * Constructor. Prepares console (System.in) for reading
    public EasyReader()
    myFileName = null;
    myErrorFlags = 0;
    myInFile = new BufferedReader(
    new InputStreamReader(System.in), 128);
    * Constructor. opens a file for reading
    * @param fileName the name or pathname of the file
    public EasyReader(String fileName)
    myFileName = fileName;
    myErrorFlags = 0;
    try
    myInFile = new BufferedReader(new FileReader(fileName), 1024);
    catch (FileNotFoundException e)
    myErrorFlags |= OPENERROR;
    myFileName = null;
    * Closes the file
    public void close()
    if (myFileName == null)
    return;
    try
    myInFile.close();
    catch (IOException e)
    System.err.println("Error closing " + myFileName + "\n");
    myErrorFlags |= CLOSEERROR;
    * Checks the status of the file
    * @return true if en error occurred opening or reading the file,
    * false otherwise
    public boolean bad()
    return myErrorFlags != 0;
    * Checks the EOF status of the file
    * @return true if EOF was encountered in the previous read
    * operation, false otherwise
    public boolean eof()
    return (myErrorFlags & EOF) != 0;
    private boolean ready() throws IOException
    return myFileName == null || myInFile.ready();
    * Reads the next character from a file (any character including
    * a space or a newline character).
    * @return character read or <code>null</code> character
    * (Unicode 0) if trying to read beyond the EOF
    public char readChar()
    char ch = '\u0000';
    try
    if (ready())
    ch = (char)myInFile.read();
    catch (IOException e)
    if (myFileName != null)
    System.err.println("Error reading " + myFileName + "\n");
    myErrorFlags |= READERROR;
    if (ch == '\u0000')
    myErrorFlags |= EOF;
    return ch;
    * Reads from the current position in the file up to and including
    * the next newline character. The newline character is thrown away
    * @return the read string (excluding the newline character) or
    * null if trying to read beyond the EOF
    public String readLine()
    String s = null;
    try
    s = myInFile.readLine();
    catch (IOException e)
    if (myFileName != null)
    System.err.println("Error reading " + myFileName + "\n");
    myErrorFlags |= READERROR;
    if (s == null)
    myErrorFlags |= EOF;
    return s;
    * Skips whitespace and reads the next word (a string of consecutive
    * non-whitespace characters (up to but excluding the next space,
    * newline, etc.)
    * @return the read string or null if trying to read beyond the EOF
    public String readWord()
    StringBuffer buffer = new StringBuffer(128);
    char ch = ' ';
    int count = 0;
    String s = null;
    try
    while (ready() && Character.isWhitespace(ch))
    ch = (char)myInFile.read();
    while (ready() && !Character.isWhitespace(ch))
    count++;
    buffer.append(ch);
    myInFile.mark(1);
    ch = (char)myInFile.read();
    if (count > 0)
    myInFile.reset();
    s = buffer.toString();
    else
    myErrorFlags |= EOF;
    catch (IOException e)
    if (myFileName != null)
    System.err.println("Error reading " + myFileName + "\n");
    myErrorFlags |= READERROR;
    return s;
    * Reads the next integer (without validating its format)
    * @return the integer read or 0 if trying to read beyond the EOF
    public int readInt()
    String s = readWord();
    if (s != null)
    return Integer.parseInt(s);
    else
    return 0;
    * Reads the next double (without validating its format)
    * @return the number read or 0 if trying to read beyond the EOF
    public double readDouble()
    String s = readWord();
    if (s != null)
    return Double.parseDouble(s);
    // in Java 1, use: return Double.valueOf(s).doubleValue();
    else
    return 0.0;
    Can anybody please tell me what's wrong with this code? Thanks

    String[] message = {
        "One, two, buckle your shoe",
        "One, two, buckle your shoe",
        "Three, four, shut the door",
        "Three, four, shut the door",
        "Five, six, pick up sticks",
        "Five, six, pick up sticks",
        "Seven, eight, lay them straight",
        "Seven, eight, lay them straight",
        "Nine, ten, this is the end",
        "Nine, ten, this is the end"
    if(n>0)
        System.out.println(message[n]);
    else
        System.exit(0);

  • What's wrong with this content type definition?

    Could someone tell me what's wrong with this content type definition? When I click "New Folder" in a custom list, it should bring two fields 1) Name 2) Custom Order. However in my case when I click new folder, I see 1) Member (which is totally
    weird) 2) custom order. Where is it getting that Member field from?
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <!-- Parent ContentType: Folder (0x0120) -->
    <ContentType ID="0x012000c0692689cafc4191b6283f72f2369cff"
    Name="Folder_OrderColumn"
    Group="Custom"
    Description="Folder with order column"
    Inherits="TRUE"
    Version="0">
    <FieldRefs>
    <FieldRef ID="{35788ED2-8569-48DC-B6DE-BA72A4F87B7A}" Name="Custom_x0020_Order" DisplayName="Custom Order" />
    </FieldRefs>
    </ContentType>
    </Elements>

    Hi,
    According to your post, my understanding is that you had an issue about the custom content type with custom column.
    I don’t think there is any issue in the content type definition, and it also worked well in my environment.
    Did you have the Member field in the project?
    I recommend you create a simple project only with one custom Order column and one custom Folder_OrderColumn, then you can add more fields one by one.
    By doing this, it will be easier to find out the root cause of this error.
    Thanks,
    Jason
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Jason Guo
    TechNet Community Support

  • What's wrong with this refresh group?

    Hello,
    I want the materialized views group refresh to refresh once per day so I created the following;
    BEGIN
    DBMS_REFRESH.MAKE(name=>'mviews_refg',
    list=>'mview1,mview2'
    next_date => SYSDATE,
    interval => 'SYSDATE + 23/24');
    END;But the issue, I am seeing the refresh done all the time in serie, what is wrong with this syntax. Please help me in fixing it and provide me the correct systax. My database version is 11.2.0.3.
    Thanks

    This for 10g but will help
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:2664480900346253895

Maybe you are looking for

  • Error while migrating from 9.2.0.1.0 to 11.1.0

    When I'm running database upgrade assistant to upgrade oracle 9i(9.2.0.1.0) to 11g(11.1.0) I'm getting following error Could not get the database version from the "Oracle Server" component. The "CEP" file "c:\app\oracle\product\11.1.0\db_1\rdbms\admi

  • From MAC to windows

    Hi, I just loaded all of my songs onto my new iPod using my Mac Powerbook. I also loaded all of the same playlists onto my wife's new iPod Nano from my Powerbook. She doesn't use Mac, she uses Windows. Now, she wants to add songs to her Nano from her

  • When viewing Facebook, the blue menu bar at the top disappears.  I can only log out by going to 'Messages' where the menu bar comes back.  Any ideas?

    When viewing Facebook, the blue menu at the top disappears.  I can only log out when I go to messages and the menu returns.  Any ideas?

  • TO-BE Process

    We are in process of launcing 11i. Can anybody provide us what should be standard TO-BE procees for different Mfg. Modules. Is there any URL is there to get detail about this. Thanks Sushil

  • Packagin material

    Hiii i am tryin to bring in stock (for a packaging material ) through MB1c ...its giving me the foll error "NO STOCK POSTING POSSIBLE FOR THIS MATERIAL" please help me figure out the error Regards maddy