Why doesnt this work, its so simple

The following piece of code I guess should print "THEY ARE EQUAL" but it doesnt. I dont know why???????????? anybody help.
String check = new String("new���".getBytes("iso-8859-1"), "iso-8859-1");
for(int i =0 ; i< check.length(); i++)
if(check.charAt(i)=='���') System.out.println("THEY ARE EQUAL");
}

You aren't comparing whether the two strings contain
the same data, you are comparing whether the two
references point to the same objects. Try it again
using the .equals() method to compare the contents of
the two strings instead of using ==.For the first time in my life have I seen DrClap err. So he is human too. amit234 is comparing characters and not Strings
I found the solution to your problem your the corresponding line in your code with this one and it would work
if(check.charAt(i)=='\u20AC') System.out.println("THEY ARE EQUAL");
happy coding

Similar Messages

  • Problem with WindowAdapter, why doesnt this work ?

    Hi
    I have created a source file with the following code:
    import java.awt.* ;
    import java.awt.event.* ;
    import javax.swing.* ;
    public class EventDemo3 extends JFrame
         EventDemo3()
              // Setter tittel, st�rrelse og gj�r det synlig
              setTitle("EventDemo3 - lukking av vindu") ;
              this.addWindowListener(new WindowAdapter() {
                   public void windowClosed(WindowEvent e)
                        System.exit(0) ;
              setSize(300, 300) ;
              setVisible(true) ;
         public static void main(String[] args)
              new EventDemo3() ;
    }It compiles and runs, but when i close the window the JVM is still running and i cant figure out why, does someone know why this doesnt work ?
    Message was edited by:
    icebyte

    Perhaps you want this instead:
    import java.awt.* ;
    import java.awt.event.* ;
    import javax.swing.* ;
    public class EventDemo3 extends JFrame
         EventDemo3()
              // Setter tittel, st�rrelse og gj�r det synlig
              setTitle("EventDemo3 - lukking av vindu") ;
              this.addWindowListener(new WindowAdapter() {
                            @Override
                   public void windowClosing(WindowEvent e)
                        System.exit(0) ;
              setSize(300, 300) ;
              setVisible(true) ;
         public static void main(String[] args)
              new EventDemo3() ;
    }

  • Why doesnt this work??

    Hi All,
    Im tryin to design a website to take an image out of the database and display it on the jsp page.
    I call the image using:
    <img src="ImageServlet?id=3" width="250" height="250" align="top">
    This calls the servlet that displays the image. The first time i call this the image is displayed. I dont store the image in the session.
    My problem is when i click a link to another page and then come back to the original page the image doesnt display. If i refresh the page it wont display. It will display when i manually right click the image and show the picture.
    What could be the cause of this. The image is their it just wont display the second time the page is called.
    Thanks for any help in advance.

    I changed the way the servlet handled the image and got it to print any error instead of throwing them. This is what is coming up.
    java.io.IOException: Stream closed
    at java.io.BufferedInputStream.ensureOpen(BufferedInputStream.java:120)
    at java.io.BufferedInputStream.available(BufferedInputStream.java:336)
    at ImageServlet.doGet(ImageServlet.java:36)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
    icationFilterChain.java:247)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
    ilterChain.java:193)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
    alve.java:260)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
    t.invokeNext(StandardPipeline.java:643)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
    a:480)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
    alve.java:191)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
    t.invokeNext(StandardPipeline.java:643)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
    a:480)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:
    2396)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
    ava:180)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
    t.invokeNext(StandardPipeline.java:643)
    at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatche
    rValve.java:170)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
    t.invokeNext(StandardPipeline.java:641)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
    ava:172)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
    t.invokeNext(StandardPipeline.java:641)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
    a:480)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
    ve.java:174)
    at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
    t.invokeNext(StandardPipeline.java:643)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
    a:480)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
    at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:22
    3)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
    :405)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
    ssConnection(Http11Protocol.java:380)
    at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java
    :508)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP
    ool.java:533)
    at java.lang.Thread.run(Thread.java:536)
    This is the servlet that generates the error.
    import javax.servlet.*;
    import javax.servlet.http.*;
    import ProductDetails.*;
    import java.io.*;
    import java.util.*;
    import java.awt.image.*;
    public class ImageServlet extends HttpServlet {
    public void init(ServletConfig config) throws ServletException {
    public void destroy() {
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, java.io.IOException {
    try
    HttpSession session = request.getSession(false);
    Product p = (Product) session.getAttribute("prod"+request.getParameter("id")+"");
    int i = p.getID();
    //if( i == Integer.parseInt(request.getParameter("id")) )
    InputStream in = p.getImage();
    response.setContentType("image/jpg"); // or whatever type of file it is.
    response.setHeader("Cache-Control","no-cache");
    response.setHeader("Expires", "0");
    response.setHeader("Pragma", "No-cache");
    response.addHeader("Cache-control", "no-store"); // tell proxy not to cache
    response.addHeader("Cache-control", "max-age=0"); // stale right away
    ServletOutputStream sout = response.getOutputStream();
    int c;
    int b = in.available();
    while((c = in.read()) != -1)
    sout.write(c);
    int imad = 0;
    System.out.println("Image called. "+ imad + " Available: " + b);
    in.close();
    in = null;
    sout.flush();
    sout.close();
    return;
    catch (Exception e)
    e.printStackTrace();
    throw new ServletException(e);
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, java.io.IOException {
    doGet(request, response);
    Product stores an Inputstream that is gotten from the database.

  • Map map = new HashMap(); -why doesnt this work in jdk 1.8.1

    Hi there,
    I'm trying to use a hashmap like this below:
    Map map = new HashMap();
    map.put("Carrots", new Integer(12));
    map.put("Potatoes", new Integer(30));
    map.put("Onions", new Integer(15));
    map.put("Apples", new Integer(40));
    map.put("Cherries", new Integer(300));
    the HashMap() does not exist in my API for some reason.
    Can anyone tell me why this may be?
    i'm using the hashmap with a stringtokenizer to search a text file line by line and increment how many times each keyword occurs.Sound efficient way of doing it?
    cheers,

    do you mean jdk 1.1.8?
    Map and the other Collections API were added in JDK 1.2. for JDK < 1.2, use Hashtable instead.

  • Why doesnt this work ( 10 line program ) ?

    import java.lang.Math;
    public class DeckTester{
         public static void main ( String[] args ){
              Deck threeOfClubs = new Deck (0, 3);
              System.out.println( threeOfClubs.suit );
              System.out.println( threeOfClubs.rank );
    class Deck
    int suit, rank;
    public Card () {
    this.suit = 0; this.rank = 0;
    public Card (int suit, int rank) {
    this.suit = suit; this.rank = rank;
    It tells me i need a return statement or something but i dont really think that is my problem. Bascially i am jsut trying to figure out how to make an object, put data int, then take out the data and print it.
    Any help appreciated. And please dont tell me "go look at tutorials" like people did last time because that doesn help. thanks

    Just have one more question for people that also know
    VB: Is useing an object to store data just like a user
    defined data type in VB?Repeat after me: Objects are not used to store data, they are used to organize related information in a meaningful way, and to represent real-life or abstract things. In this case, your object has a suit and a rank, which implies it a playing card, so your class should be called Card (not Deck!).

  • Why isnt this working urgent please help

    why isnt this working im trying to connect a panel to a scrollpane the panel will contain several dozen text fields
    the scrollpane shouls be about 350, 450 , but the pane is 350
    by 1200 the problem now is that the scorllbar isnt created and even when I explictly create it it contains no knob, and it will
    not scroll up or down please someone help this is urgent
    import java.awt.*;
    import com.sun.java.swing.*;
    public class ScrollDemo extends JPanel {
         private Rule columnView;
         private Rule rowView;
         private ScrollablePicture picture;
         class UnitsListener implements ItemListener {
              public void itemStateChanged(ItemEvent e) {
                   if (e.getStateChange() == ItemEvent.SELECTED) {
                        // Turn it to metric.
                        rowView.setIsMetric(true);
                        columnView.setIsMetric(true);
                   } else {
                        // Turn it to inches.
                        rowView.setIsMetric(false);
                        columnView.setIsMetric(false);
                   picture.setMaxUnitIncrement(rowView.getIncrement());
    public ScrollDemo() {
         Two t = new Two(columnView.getIncrement());
              JScrollPane pictureScrollPane = new JScrollPane(t);
              pictureScrollPane.setPreferredSize(new Dimension(300, 250));
              pictureScrollPane.setColumnHeaderView(columnView);
              pictureScrollPane.setRowHeaderView(rowView);
         public static void main(String s[]) {
              JFrame frame = new JFrame("ScrollDemo");
              frame.setContentPane(new ScrollDemo());
              frame.setVisible(true);
    import java.awt.*;
    import com.sun.java.swing.*;
    public class Two extends JPanel implements Scrollable{
    private JPanel ivjJPanel3 = null;
         private JScrollPane ivjJScrollPane1 = null;
         private int maxUnitIncrement = 1;
    public Two(int m)
         getJPanel1();
         maxUnitIncrement = m;
         setSize(300,1200);
    private void getJPanel1() {
                   setLayout(null);
                   setSize(250,1200);
                   add(getJLabel1(), getJLabel1().getName());
    public Dimension getPreferredScrollableViewportSize() {
              return getPreferredSize();
         public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation,
         int direction) {
              if (orientation == SwingConstants.HORIZONTAL)
                   return visibleRect.width - maxUnitIncrement;
              else
                   return visibleRect.height - maxUnitIncrement;
         public boolean getScrollableTracksViewportHeight() {
              return false;
         public boolean getScrollableTracksViewportWidth() {
              return false;
         public int getScrollableUnitIncrement(Rectangle visibleRect,
                                                      int orientation,
                                                      int direction) {
              //Get the current position.
              int currentPosition = 0;
              if (orientation == SwingConstants.HORIZONTAL)
                   currentPosition = visibleRect.x;
              else
                   currentPosition = visibleRect.y;
              //Return the number of pixels between currentPosition
              //and the nearest tick mark in the indicated direction.
              if (direction < 0) {
                   int newPosition = currentPosition -
                                       (currentPosition / maxUnitIncrement) *
                                       maxUnitIncrement;
                   return (newPosition == 0) ? maxUnitIncrement : newPosition;
              } else {
                   return ((currentPosition / maxUnitIncrement) + 1) *
                        maxUnitIncrement - currentPosition;
         public void setMaxUnitIncrement(int pixels) {
              maxUnitIncrement = pixels;

    I personally didn't play with swing components when they were in the com.sun.java.swing state, but I have a strong feeling it is very buggy and could be causing your problem.
    Before posting gui issues, please use a newer API, even jdk1.1 would be fine, anything would be better than what your using.
    you wrote: I dont care if its javax.swing or
    com.sun.java.swing
    I would also gather from this statement that your attitude could be one of your other issues.

  • Why doesnt pages work on my ipad 2 and what is the alternative

    why doesnt pages work on my ipad2 and what is the alternative

    Assuming that your iPad isn't on iOS 5 (your current version is shown in Settings > General > About > Version on the iPad), then to update to it you first need iTunes 10.5 on your computer - if you don't have itunes 10.5 then you can download it from here http://www.apple.com/itunes/download/.
    To update your iPad connect it to your computer's iTunes and select it on the left-hand side of iTunes. Then, if the update isn't automatically detected and you are prompted to download it, on the right-hand side on the Summary tab click the Check For Updates button

  • T61 does it have a mic if so why doesnt it work ?????????

    Dear Gurus,
    Hi. I have been a proud buyer of the lenovo T61 machine for almost a year now and I am proud my machine is still few hours old which was used only for the two problem resolutions(first it was restoration issues and then battery issues).
    Finally I got replacement battery now I felt that my machoine doesnt have mic. I did try to look for it and then after a long serach on the internet did find out that my machine did have a mic but its not working. 
    Kindly lenovo lovers plz help me out how to make this work. At times I feel bad that I bought the most reliable name (THINKPADS) in the notebook industry or at times i felel that may be I was the unlucky ones. I need urgent help as I am about to go on my business trip and without a mic i will be stuck.
    Thanks in advance waiting for a reply soon.  
    THINKPADT61 / 7662CTO / T7500 / 100GB 7200RPM / 2GB RAM / 14.1 WIDE SCREEN / NVIDIA 140MS / 4965AGN / BT / WINDOWS XP
    Solved!
    Go to Solution.

    You did not mentioned anything about the driver update in you previous post. Anyway, I you suspect that the issue is cause by the driver then you shoud go back to the previous dirver. I do not know about Windows XP but you can do that in Vista from device manager. Other way to get the driver (or the previous version of it) is to go to the Lenovo Support & Downloads page (you should have the linkg in your browser preferences).
    Finally, if nothing works then you still have the option to call Lenovo.
    Hope this helps.
    ThinkPad T500 2242-CTO P8600 / 4GB RAM / WSXGA+ / HDD Fujitsu 7200rpm 1TB / 6 Cell Sony / Windows 8 Pro 64-bit
    ThinkPad Tablet 2
    ThinkPad X61s 7669-3KG Windows 7 Home Premium 32-bit

  • Why does this work?

    I've been practicing some IPSec VPN scenarios, starting with the typical site-to-site VPN:
    Router A
    crypto map mymap 10 ipsec-isakmp
    set peer 1.1.1.2
    set transform-set myset
    match address 101
    access-list 101 permit ip 10.1.1.0 0.0.0.255 10.1.2.0 0.0.0.255
    Router B
    crypto map mymap 10 ipsec-isakmp
    set peer 1.1.1.1
    set transform-set myset
    match address 101
    access-list 101 permit ip 10.1.2.0 0.0.0.255 10.1.1.0 0.0.0.255
    This works as expected. Traffic from 10.1.1.x on Router A gets picked up by the crypto map and sent to RouterB and vice versa. What is confusing me is a more advanced scenario where I'm tunnelling GRE over IPSec with OSPF (why? Because I can).
    http://www.cisco.com/en/US/tech/tk583/tk372/technologies_configuration_example09186a008009438e.shtml
    Everything works just fine, but I'm bothered by the ACLs being used in the example. I don't see how everthing should be working- OSPF is fat and happy, and if I ping one spoke from another spoke from a loopback interface, it works as well. In this case, is the network traffic being picked up by the Tunnel interface first, and all the crypto map sees is GRE traffic by the time the packets make it that far?

    Ian
    You ask a question about the access lists and I believe that it will be easier to answer the question if we have the access lists to refer to. So here they are:
    7206:access-list 130 permit gre host 14.36.88.6 host 14.38.88.40access-list 140 permit gre host 14.36.88.6 host 14.38.88.20access-list 150 permit gre host 14.36.88.6 host 14.38.88.102610:access-list 120 permit gre host 14.38.88.10 host 14.36.88.63620:access-list 110 permit gre host 14.38.88.20 host 14.36.88.6
    3640:
    access-list 100 permit gre host 14.38.88.40 host 14.36.88.6
    one of the first things to understand here (and you briefly mention it in your post) is that they are running OSPF dynamic routing protocol over the tunnels. So each router sees the path to get to the other router as being through the tunnel. So when the 2610 wants to get to the 7206 it will send that traffic to the tunnel interface. The tunnel interface will encapsulate the original packet in a GRE header. So yes the only thing that the access list will see is GRE traffic.
    Anything that goes through the tunnel (whether it be a data packet or an OSPF routing update) is encapsulated in a GRE header and the access list does not see the original data but sees only GRE.
    HTH
    Rick

  • Questions, Extreme begginer - Why wont this work.

    /* My Java Program
    Failing To Compile 2009 - CurrentDate()
    /* Importing */
    import java.util.Scanner;
    import acm.graphics.*;
    import acm.program.*;
    class run {
         public static void main(String args[]){
         //Variables
         Scanner ninjatext = new Scanner(System.in);
         Scanner Clarinet_Request = new Scanner(System.in);
         System.out.println(ninjatext.nextLine());
         double pye, var1, ans;
         String yodawg;
         var1 = 2;
         pye = 3.14;
         yodawg ="I heard you like saxaphones  ";
         ans = var1/pye;
              System.out.println("Hello Cruel World?");
              System.out.print(yodawg);
              System.out.print("So i bought you ");
              System.out.print(ans);
              System.out.println(" Saxxes");
              System.out.println("So How many Clarinets Would you like????");
              System.out.println("Enter Number::");
              System.out.println("So " + Clarinet_Request.nextLine() + " Is how many clarinets You would like? Cool");
         /*Please end up working*/
         // Declaring Variables Semi-Randomly Works, Right?
         String test1 = "Ok i hope this works";
         int test2 = 10;
         double test3 = 4.9;
         int test4 = test2/test3; //Random Weird Awnser right???
         System.out.println(test2 + "Divided by" + test3 + "Is Equal To" + test4);
         /* This all should work, at least in theory.... But it wont right? */
         /** What have i gotten myself into? Oh well it sounds like it should work */
         Console console = System.console();
         String username = console.readLine("Lets Do This?: ");
         if (/* String? */username == "yes" || "Yes" || "YES"){
              testingthiscrap LeroyJenkins = new testingthiscrap
              LeroyJenkins.LetsDoThis()
         /* Guaranteed to not work */
    public class testingthiscrap extends GraphicsProgram {
         /** Runs the program */
         public void LetsDoThis() {
              GRect rect = new GRect(100, 50, 100, 100 / PHI);
              rect.setFilled(true);
              rect.setColor(Color.RED);
              add(rect);
              GOval oval = new GOval(150, 50 + 50 / PHI, 100, 100 / PHI);
              oval.setFilled(true);
              oval.setColor(Color.GREEN);
              add(oval);
    /** Constant representing the golden ratio */
         public static final double PHI = 1.618;
    /* Standard Java entry point */
    /* This method can be eliminated in most Java environments */
         public static void main(String[] args) {
              new FeltBoard().start(args);
         }//If anything i just typed i now feel heroic.
         // public static void
         Ok, sorry if the titles not good enough but i am a php programmer between begginer and intermediate but who wants to know java so i can say write a applet or something that can run from the desktop directly, also i wanted to lean OO and it in php confuses me infinately so i decided in the context of knowing nothing i might pick it up better thus java.
    So most of what im doing is confusing to me so i just tried to type some code (Well the first 20 maybe lines i compiled and tested but after that i couldnt test so i just ran with it. Today i tried to compile and poof, nothing.
    Any clues what im doing wrong and what i should do instead?
    BTW this stuff feels weird, i feel like to take imput it should have a html form or something. I dunno.
    also i dont even seem to have these acm packages im trying to import, any clue why?

    jman888 wrote:
    Ok, sorry if the titles not good enough but i am a php programmer between begginer and intermediate but who wants to know java so i can say write a applet or something that can run from the desktop directly, also i wanted to lean OO and it in php confuses me infinately so i decided in the context of knowing nothing i might pick it up better thus java. Ok?
    So most of what im doing is confusing to me so i just tried to type some code (Well the first 20 maybe lines i compiled and tested but after that i couldnt test so i just ran with it. Today i tried to compile and poof, nothing.I assume you got a compile time error, if so next time you post a question incorporate this piece of information.
    Any clues what im doing wrong and what i should do instead?I can take a stab at your code.
    BTW this stuff feels weird, i feel like to take imput it should have a html form or something. I dunno.One step at a time
    String yodawg;
    yodawg ="I heard you like saxaphones  ";This is not an error but plain weird IMHO, if you are declaring a variable then initializing it, you might as well do it all on one line.
    if (/* String? */username == "yes" || "Yes" || "YES"){
      testingthiscrap LeroyJenkins = new testingthiscrap
      LeroyJenkins.LetsDoThis()
    }This code will not compile and should produce one of possible many compiler errors. The condition inside the if statement requires each condition to be independent of one another. e.g. (username == "yes" || username = "Yes" || username == "YES").
    This also represents one of the most common errors presented to new comers. Equivalence of Objects such as Strings are compared using a method .equals() and not the term "==". The latter actually compares two Strings by the address stored in memory.
    class runBy convention all Class names begin with a capital letter
    Also it appears that the class run contains main method and an inner class in which itself contains a main method. I will conclude right here that you are biting off far more then you can chew. Start with the basics, e.g. Google for Java tutorials and start from "hello world" then make your way from there. Tackle one problem at a time and learn the concepts of the tutorial which will hopefully stay with you, as these fundamental concepts will be your foundation to development using the Java language.
    Mel
    Edited by: Melanie_Green, apparently CODE tags don't like me tonight

  • Why aint this working!!!couldnt find answer in forums

    Hi,
    I come accross a problem with comparing 2 strings. Well i got a program that reads a file and displays its contents on the screen. Well, as the contents of the file changes i wont the program to add new text but not txt that had been already inputted.
    My solution was to read the file and then compare it to the text already inputted. Below is what i have written but it doesnt work, its either displays the text or not.
    FileInputStream file = new
    FileInputStream ("send.txt");
    BufferedReader reader = new BufferedReader(new InputStreamReader(file));
    String text = new String ("" + reader.readLine());
    if (text == oldtext) {
    System.out.println(text);
    oldtext = text;
    file.close();
    My Regards,

    And reader.readLine returns a string as it is - you're creating THREE Here:
    reader.readLine returns 1 string.
    ""+<reader.readLine result> creates another.
    new String() creates a third.

  • Why doesnt this forum keep me logged in? Everytime I sign in I get error?

    Alright, why doesnt the apple forums allow you to stay logged in?
    Also, every time I do log in, I always get an error messaging saying:
    Page Not Found
    Whats up with this?

    Sometimes the Page Not Found error appears when a thread has been taken down by the moderators for a violation of the TOU (Terms of Use).
    And sometimes a specific User ID will be blocked - temporarily or permanently - if the User has posted something considered inappropriate. Yes, it has happened to me when I was ranting about inappropriate subject.
    If those are not the problems, you can try Safari -> Reset Safari ... Then put a check mark on every itme to clear cookies and caches that might be creating a problem for you.
    Hope that hels.

  • Why doesnt it work

    ive tried everything why wont it work, it just print back in the order i put it in. I'm trying to sort alphabetically.
    public class Sortstringskinda
        public static void sort(String names[])             
            String temp;                                   
            for(int i = 0; i < names.length - 1; i++)       
                for(int ii = 0; ii > names.length - 1; ii++)
                    if(names[ii].compareToIgnoreCase(names[ii+1])<0)              
                        temp = names[ii];                   
                        names[ii] = names[ii+1];             
                        names[ii+1] = temp;                 
        public static void main(String[] args)
             //declares an array to be sorted
             String names[] = {" Chen"," Lin"," Huang"," Zhu"," Zhang"," Wu","Wang"," Cai"," Sato"," Suzuki"," Takahashi"};
            // for(int i = 0; i < names.length; i++)     
            //     System.out.println(names);
    sort(names);
    System.out.println("\nAfter sort():\n");
    for(int i = 0; i < names.length; i++)
    System.out.println(names[i]);

    public class Sortstringskinda
        public static void sort(String names[])             
            String temp;
            for(int i = 0; i < names.length; i++ )       
                for(int ii = 0 ; ii < names.length-1; ii++)
                    if(names.compareToIgnoreCase(names[ii]) < 0) /*choose order*/
              temp = names[ii];
    names[ii] = names[i];
    names[i] = temp;
    public static void main(String[] args)
    //declares an array to be sorted
    String names[] = {"Chen","Lin","Huang","Zhu","Zhang","Wu","Wang","Cai","Sato","Suzuki","Takahashi"};
    // for(int i = 0; i < names.length; i++)
    //System.out.println(g.compareToIgnoreCase(h));
    sort(names);
    System.out.println("\nAfter sort():\n");
    for(int i = 0; i < names.length; i++)
    System.out.println(names[i]);

  • Why aint this working???

    have pasted object thru a constructor like this:
            Write screen   = new Write(ring);
    //and rezive it here in the constructor
         public Write(Object ring)
              buffer = ring;
    // and use it like this:
              System.out.println(buffer.remove()); // This line gets an errorSo why is this error comming?
    cannot resolve symbol method remove()

    public class RingBuffer
        public static void main(String[] args)
             Ringen ring = new Ringen();
             Write screen   = new Write(ring);  // Henter tekst fra ringbuffer og skriver den ut p? skjermen.
             Generate genr  = new Generate();   // Lager tekst "automatisk" og legger den inn i ringbufferen.
             Input_txt intxt= new Input_txt(ring);  // Lar brukeren taste inn noen ord som lagres i ringbufferen.
             screen.start(); //
             genr.start();   //  Starter tr?dene.
             intxt.start();  //
    public class Write extends Thread
         private Object buffer;
         public Write(Object ring)
              buffer = ring;
         synchronized public void run()
              //Ringen buffer = new Ringen();
              while(true){
                   try{
                        System.out.println(buffer.remove()); // Pr?ver ? skrive ut hvert sekund
                        Thread.sleep(1000);
                   }//end try
                   catch(InterruptedException e){
                        System.out.println(e);
              }//end while
    import java.io.*;
    public class Input_txt extends Thread
         Object buffer;
         public Input_txt(Object ring)
              buffer = ring;
         synchronized public void run()
              try{
                        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
                        System.out.println("Skriv inn noe tull");
                        String inTxT = in.readLine();
                        buffer.insert(inTxT);
              catch(Exception e) { System.out.println(e);}
    public class Ringen implements Buffer
         private static final int BUFFER_SIZE = 10;
         int in, out;  // peker p? f?rste ledige og siste okuperte.
         int count;    // Teller hvor mange objekter som er i bufferen.
         private Object[] buffer;
         public Ringen()
              count = 0;
              in = 0;
              out = 0;
              buffer = new Object[BUFFER_SIZE];
         public void insert(Object item)
              while (count == BUFFER_SIZE)
                   ;// do nothing..
              // Legger til et object i bufferen
              ++count;
              buffer[in] = item;
              in = (in + 1)% BUFFER_SIZE;
         public Object remove()
              Object item;
              while (count == 0){
                   try{
                        System.out.println(buffer[0]);
                        Thread.sleep(4000);
                   }//end try
                   catch(InterruptedException e){
                        System.out.println(e);
              }//end while
              --count;
              item = buffer[out];
              out = (out + 1) % BUFFER_SIZE;
              return item;
    public interface Buffer
         // producers call this method
         public abstract void insert(Object item);
         // consumers call this method
         public abstract Object remove();
    }

  • Why doesnt this simple thing work?

         * Increment the display value by one, rolling over to zero if the
         * limit is reached.
        public void increment()
            ++ value;  
            if(value = limit)
                value = 0;
    }I won't this method to do what the method header description says but when compiles it says "incompatible types - found int but expected boolean".

    if(value = limit)You're using the wrong equal sign operator. This code is trying to set the value of "value" equal to "limit", an operation that returns an int, to my knowledge. This is because the '=' operator is Java's assignment operator. You want java's comparison operator, '=='. If you use:
    if(value == limit)your thing should compile just fine. Whether it works or not, I can't say =)
    SheepNine

Maybe you are looking for

  • How to open new window webi report using open doc?

    Hi All, i have created URL using open doc in Bi 4.0 .please find the below my code. http://fcvws975/BOE/OpenDocument/opendoc/openDocument.jsp?iDocID=AeX5DoctKBhGv1AiV2oibxU&sIDType=CUID&sType=BI workspace&sRefresh=Y" title="" target="_blank" nav="doc

  • -1073741819 code using Report Generation with LV 6.1

    I'm studing about the Report Generation Functions with LV 6.1, and I'm trying to run some example about it, but the programs sends the next error: "Error -1073741819 ocurred at unknown System error in Font Style.vi> Set report font.vi>Easy text repor

  • In Mountain Lion, I would like to receive messages notifications in my notifications center WITHOUT it opening up the application.

    I would like for my notifications to just show something like a red badge with maybe a number by it that represents the number of unread messages I have. I DO NOT want the OS to open the Messages app every time I get a new message. It takes me away f

  • Screen black, but iBook still runs

    I have had a white iBook G3 for over 5 years. I had just closed it and put it to sleep. When I opened it up not long after that, it seemed to wake up (breathing light went away), but the screen was all black. I restarted it and it booted up as normal

  • SRM  with HR integration

    Hi Experts, We are currently Using  the SRM 4.0 with support pack 9 currently.  Till I recieved the requests from business for creation of SRM user access, so I am creating the SU01 data and intergrating to the Organization structure using Users_Gen.