?? (string1 == string2) ??

Can someone please explain the rules here
public class A {
public static void main(String args[]) {
String s1 = "abc";
String s2 = "abc";
System.out.println(s1 == s2);
String s3 = new String("abc");
System.out.println(s1 == s3);
I was expecting "false" "false" but the first was is true - WHY?

As joeldi pointed out, if they are both pointing to (referencing) the same bit of memory, they are equal (==), like so:
String s1 = "abc";
String s2 = s1;
System.out.println(s1==s2);This will return true.
Doing this isn't so different.
String s1 = "abc";
String s2 = "abc";Because s1 and s2 are being given exactly the same value, the compiler is smart enough to save memory and point them both at the same "abc" literal (is this what they mean by interning?). And since Strings are immutable (can't be changed) it doesn't matter in the slightest, since s1 can't possibly upset the data in s2.
Cheers,
Radish21

Similar Messages

  • Copy(string1, string2)

    Hi,
    In Forms pl/sql you can use this command to copy between two strings, where you can dybnamically build the string names. It doesn't seem to be in database pl/sql, anyone know how to do this in database pl/sql please ??????
    TIA
    Tony

    Note the this has been answered in the Database-General forum
    Re: copy(string1, string2)
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Bash: "expr index string1 string2" gives "syntax error"

    In a bash script, I was trying to use the command
    expr index string1 string2
    to find the position of string2 in string1, but this does not work on OS X while it works ok on several Linux machines. Reading the man page, I realized expr does something quite different on OS X than on Linux.
    Can anybody suggest which command I should use to get the same functionality of the above on OS X?
    Thanks
    Andreas

    Hi Ken,
       Wow! That's something you don't see every day; I'm really impressed. I had had a tough day too. Later I thought of a funny answer in which I blamed everything on the crazy shell I use. The difference between the two answers is just the flow of karma but stopping the flow of negative by saying something is a real and difficult choice and yours shows character. I'm sorry for going on too much but such things matter more than machines.
       On the other hand, you're a royal pain in the ... just kidding. You're a strict task master but right; I read in the man page about it returning zero and forgot. However, mathematically it isn't too difficult; you just have to use modular arithmetic. In zsh, (I can learn) it would look like:
    test=aabbcc
    echo $(( ( ${#test%%[bc]*} + 1 )%( ${#test} + 1 ) ))
    In bash, it would look like:
    test=aabbcc
    testtmp=${test%%[bc]*}
    echo $(( ( ${#testtmp} + 1 )%( ${#test} + 1 ) ))
    Gary
    ~~~~
       In science it often happens that scientists say, 'You know that's a really good argument; my position is mistaken,' and then they actually change their minds and you never hear that old view from them again. They really do it. It doesn't happen as often as it should, because scientists are human and change is sometimes painful. But it happens every day. I cannot recall the last time something like that happened in politics or religion.
             -- Carl Sagan, 1987 CSICOP keynote address

  • String1 === string2 make me confuse

    ------------------------A-------------
    String s1="hello "; //string "hello " ended with a blank
    String s2="world";
    String s3="hello world";
    s1+=s2;
    System.out.println(s3==s1);
    ------------------------B------------
    String ss1="hello world";
    String ss2="hello world";
    System.out.println(ss1==ss2);
    if the output of statement - A is false then why the output of statement - B is true?
    plz ans...
    thnx

    To be honest, I can't tell you the underlying
    mechanics,Strings are pooled internally meaning that only one copy of a String literal, such as "hello", is ever stored. So each String literal is uniquely define by an object reference. If you know what you're doing you can utilize this fact to use == to compare Strings. So even thought this "feature" has it's roots in an implementation technique (pooling) the bahaviour is defined by the language. This means, again if you know what you're doing, it'ss a perfectly kosher way to compare Strings using ==.
    Pooling is also used by some Java implementations to store small Integer literals. Sun for example pools -127 to 128 I think.
    Integer i1 = new Integer(5); // an object reference
    Integer i2 = new Integer(5); // another object reference
    if (i1==i2)  // my god they're equal ?
      System.out.println("Small Integer literals are pooled");The above == comparision "should" be false but istn't because of pooling.
    The difference is that this behaviour is an implementation artefact and NOT part of the language so it can never be utilized the way String pooling can.

  • How to find the first occurrence of a string2 in string1

    Hello
    I've got a string, and I want to know where '-' occurs
    the first time. I mean, in 'hello-world', the first
    one is position 5.
    In C++, I've got:
    Result      = strcspn(string1, string2);
    How can I do it in Java?
    Thank you very much.

    String.indexOf()...read the API.

  • Shift string1 by 3 places right.

    code ->
    data: string1(10) type c value 'abcdefghij',
          string2 like string1.
    write:  / 'Before Manipulations : ',
            / 'string1 = ',string1,
            / 'string2 = ',string2.
    string2 = string1.
    shift string1.
    write : / 'after one shift first letter is gone :-) (leftShift)',
              ' ', string1.
    write : / 'after the shift operation there is a permanent change in',
              'the field value of string1'.
    shift string1 by 3 places right.
    write : / 'after shifting 3 places on the right-', string1,
            / 'DOUBT - only ij has gone, but hij should have gone right ?'.
    write : / 'string2 also has same as string1 had initially-', string2.
    shift string2 by 3 places right.
    write : / 'after shifting 3 places on the right-', string2.
    Doubt has been marked in the code itself. This is my first post. Please do explain me concept , in the above code,if i am wrong.

    It works in STRING2 because you never did an initial shift to the left. 
    If you did want this to work in the string... you would have to find out the length of the string and then shift on that offset.
    data: stlen type i.
    shift string2.
    stlen = strlen( string2 ).
    shift string2+0(stlen) by 3 places right.
    Regards,
    Rich Heilman

  • Using Instr in Cursors or Loops...?

    Can anyone suggest me how to use "Instr" to find one parameter string in another parameter string, finding if one string is present in another using loops..??
    Edited by: user11339127 on Jul 1, 2009 11:04 PM

    You can use INSRT to find the position of your string in a given string.
    e.g:  select instr('navnit','av') from dual;  --sql
    PL/SQL--
    declare
       pos number;
    begin
      pos := instr('<string1>','<string2'>; or you can write in case of forms as pos:=instr('<:datablock>.<item>','<string to found');
      if pos = <some value> then
          <do something
      end if;
    end;  
    {coe}
    Similarly , you can extend your code.
    Hope it helps.
    +Please mark answer as helpful / correct, if it helps you+
    Navnit                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Pacman - his error messages - and clarity

    first
    [root@gateway ~]# pacman -Syu
    :: Synchronizing package databases...
    current [################] 100% 41K 12.7K/s 00:00:03
    extra [################] 100% 164K 19.9K/s 00:00:08
    Targets: abiword-2.0.12-1 dbh-1.0.20-1 doxygen-1.3.9.1-1 evolution-2.0.2-2
    evolution-data-server-1.0.2-1 flac-1.1.1-1 gaim-1.0.1-1 gal-2.2.3-1
    gdm-2.6.0.5-2 gimp-2.0.5-1 glib2-2.4.7-1 gmp-4.1.4-1
    gnome-panel-2.8.1-1 heimdal-0.6.2-1 gnome-vfs-2.8.2-1 gqview-1.4.5-1
    jack-audio-connection-kit-0.99.0-1 gst-plugins-0.8.5-1
    gstreamer-0.8.7-1 gtk2-2.4.13-1 gtkhtml-3.2.3-1 imagemagick-6.1.1-1
    imlib-1.9.15-1 iptables-1.2.11-3 libogg-1.1.2-1 libsoup-2.2.1-1
    libtiff-3.6.1-4 libvorbis-1.1.0-1 man-pages-1.69-1 mozilla-1.7.3-1
    mozilla-firefox-0.10.1-2 nautilus-2.8.1-1 perl-html-parser-3.36-1
    reiserfsprogs-3.6.19-1
    Total Package Size: 94.8 MB
    Proceed with upgrade? [Y/n]
    :: Retrieving packages from current...
    abiword-2.0.12-1 [################] 100% 3683K 29.3K/s 00:02:05
    doxygen-1.3.9.1-1 [################] 100% 1278K 23.1K/s 00:00:55
    gaim-1.0.1-1 [################] 100% 3964K 27.2K/s 00:02:25
    gimp-2.0.5-1 [################] 100% 10290K 25.7K/s 00:02:24
    glib2-2.4.7-1 [################] 100% 1082K 25.8K/s 00:00:41
    gmp-4.1.4-1 [################] 100% 240K 32.0K/s 00:00:07
    gqview-1.4.5-1 [################] 100% 298K 25.1K/s 00:00:11
    gtk2-2.4.13-1 [################] 100% 6229K 24.6K/s 00:04:13
    imagemagick-6.1.1-1 [################] 100% 4317K 24.9K/s 00:02:53
    imlib-1.9.15-1 [################] 100% 535K 36.3K/s 00:00:14
    iptables-1.2.11-3 [################] 100% 243K 23.2K/s 00:00:10
    libogg-1.1.2-1 [################] 100% 19K 14.6K/s 00:00:01
    libtiff-3.6.1-4 [################] 100% 450K 23.6K/s 00:00:19
    libvorbis-1.1.0-1 [################] 100% 451K 24.2K/s 00:00:18
    man-pages-1.69-1 [################] 100% 3638K 28.5K/s 00:02:07
    mozilla-firefox-0.10.1-2 [################] 100% 11678K 27.3K/s 00:02:52
    reiserfsprogs-3.6.19-1 [################] 100% 441K 29.7K/s 00:00:14
    :: Retrieving packages from extra...
    dbh-1.0.20-1 [################] 100% 25K 7.9K/s 00:00:03
    evolution-2.0.2-2 [################] 100% 10527K 15.9K/s 00:02:31
    evolution-data-server-1. [################] 100% 1330K 12.0K/s 00:01:50
    flac-1.1.1-1 [################] 100% 587K 20.6K/s 00:00:28
    gal-2.2.3-1 [################] 100% 1326K 16.9K/s 00:01:18
    gdm-2.6.0.5-2 [################] 100% 2805K 28.6K/s 00:01:38
    gnome-panel-2.8.1-1 [################] 100% 2705K 24.5K/s 00:01:50
    heimdal-0.6.2-1 [################] 100% 1297K 17.6K/s 00:01:13
    gnome-vfs-2.8.2-1 [################] 100% 1479K 27.2K/s 00:00:54
    jack-audio-connection-ki [################] 100% 186K 26.6K/s 00:00:07
    gst-plugins-0.8.5-1 [################] 100% 1940K 19.0K/s 00:01:42
    gstreamer-0.8.7-1 [################] 100% 1511K 21.9K/s 00:01:09
    gtkhtml-3.2.3-1 [################] 100% 1246K 20.7K/s 00:01:00
    libsoup-2.2.1-1 [################] 100% 222K 29.2K/s 00:00:07
    mozilla-1.7.3-1 [################] 100% 16636K 25.8K/s 00:02:12
    nautilus-2.8.1-1 [################] 100% 4109K 10.0K/s 00:02:35
    perl-html-parser-3.36-1 [################] 100% 78K 24.1K/s 00:00:03
    checking package integrity... done.
    loading package data... done.
    checking for file conflicts...
    error: the following file conflicts were found:
    heimdal: /usr/man/man8/rshd.8.gz: exists in filesystem
    errors occurred, no packages were upgraded.
    [root@gateway ~]# pacman -Ql /usr/man/man8/rshd.8.gz
    Package "/usr/man/man8/rshd.8.gz" was not found.
    [root@gateway ~]# pacman -Qo /usr/man/man8/rshd.8.gz
    /usr/man/man8/rshd.8.gz is owned by netkit-rsh 0.17-2
    [root@gateway ~]# pacman --version
    .--. Pacman v2.9.2
    / _.-' .-. .-. .-. Copyright (C) 2002-2004 Judd Vinet <[email protected]>
    '--' This program may be freely redistributed under
    the terms of the GNU General Public License
    [root@gateway ~]#
    Little addon ... maybe pacman could say something about "overwriting" files...
    if its intended to.. or should never ever happen... whatever.. maybe with msg's the pkg-distributer made himself (cuz at least he should know WHY of IF it should happen )
    this could be achieved by putting info in the pgk that there will be files to overwrite... so the user still is able to say "oh no don't touch it!" if he doesn't want pac'y to do that...
    like:
    REWORKDESTINATION=" /usr/man/man8/rshd.8.gz  /foo/bar"
    REWORKMESSAGE="1. just cuz im funny... <split> 2. heavy bugs fixed"
    [root@gateway ~]# pacman -S heimdal
    Targets: heimdal-0.6.2-1
    Total Package Size: 1.3 MB
    Proceed with upgrade? [Y/n]
    checking package integrity... done.
    loading package data... done.
    checking for file conflicts...
    error: the following file conflicts were found:
    heimdal: /usr/man/man8/rshd.8.gz: exists in filesystem
    reworkinfo: Just cuz im funny...
    do you want to overwrite? (YES/no) :_
    so you could also -f pac'y and he simply overwrites exept things on the <b>HoldPkg !</b> (so you still feel save with some things )
    secondly
    it would be nice to make pacman capable to download/install pgk with given versions... but as far as i see there are a lot threats about that
    thirdly
    it would also be nice if a pkg you install could add things to the pacman.conf like NoUpgrade and HoldPkg. ... eg. updating cups ... it saves the configfiles.. yeah... but as .pacsave and cups is after restarting the deamons unuseable cuz it loads with the new ones ... the other way round would be nicer...
    so if you install cups the first time the pkg it self writes into pacman.conf:
    NoUpgrade /etc/cups/cupsd.conf /etc/cups/classes.conf /etc/cups/client.conf /etc/cups/mime.convs /etc/cups/mime.types /etc/cups/printes.conf
    maybe with a update function like:
    Syntax: update(file, method, string1, string2);
    example:
    update(pacman.conf,add,"NoUpdate NoUpgrade /etc/cups/cupsd.conf /etc/cups/classes.conf /etc/cups/client.conf /etc/cups/mime.convs /etc/cups/mime.types /etc/cups/printes.conf, )
    and when you remove the pkg it does automatically:
    update(pacman.conf, remove, "NoUpgrade /etc/cups/cupsd.conf /etc/cups/classes.conf /etc/cups/client.conf /etc/cups/mime.convs /etc/cups/mime.types /etc/cups/printes.conf", )
    this could also work with a substitute-method so in pkg-updates you can also update pacman.
    i think that would heavily increase the power of pacman - wich already is a realy mighty thing

    I like 1 and 3.... very good ideas - especially number 1.. it'd be nice to have overwrite functionality in packages
    about number 2 - this issue has been brought up ad nauseum.... Arch is considered by users and developers a "bleeding edge distro" - that is, Arch uses the newest packages, assuming they work.  allowing users to manually grab a non-bleeding edge package, or even downgrade their packages is, for lack of a better phrase, against policy.  If something is not functional in a given package, then Arch as a whole should be downgraded until the package is working.  If a new version replaces the old with differing functionality, the packages should be installed side-by-side (as is the case with gtk1 & gtk2, imlib & imlib2, and many more).
    In a bleeding edge distro, downgrading a package simply because a user "likes SomePackage 0.9 better than 1.0" is not worthwhile.  Package management would become so much more difficult and require much more space.
    If there is a problem with a package (i.e. "I upgraded to Blah 0.6.5 from 0.6.3 and it doesn't work now") then the problem is most likely on your system and should be fixed.  Blame the developers, blame yourself, whatever... the fact of the matter is you need to expect this sort of thing with Arch...

  • How to implement "if/then/else" or "case" logic in a Statement Expression?

    I need a loop in my test sequence, so I define a Locals.LoopIndex which is of type Number, and I also define a Locals.PromptMessage, which is of type String. Within the loop body, have a statement step, in which I want to assign Locals.PromptMessage different strings according to the value of Locals.LoopIndex. The logic is like this (in suedo code)
    case Locals.LoopIndex:
    1: Locals.PromptMessage = "string1";
    break;
    2: Locals.PromptMessage = "string2";
    break;
    or
    if (Locals.LoopIndex == 1)
    then Locals.PromptMessage = "string1";
    else if (Locals.LoopIndex == 2)
    then Locals.PromptMessage = "string2";
    How can I implement this in the Statement Expression?
    Thanks!

    You can use the conditional expression (not sure what it is called). Syntax is Locals.variable=(BooleanExpression?ValueIfTrue:ValueIfFalse). To implement your pseudo code it would look like this:
    Locals.PromptMessage=(Locals.LoopIndex==1?"string1":"string2")
    This means the same as:
    If Locals.LoopIndex=1 then
    Locals.PromptMessage = "string1"
    Else
    Locals.PromptMessage = "string2"
    End If
    Another way to do it is like this, but the first method is preferred:
    Locals.LoopIndex==1?(Locals.PromptMessage="string1")Locals.PromptMessage="string2") -- must use parenthesis as shown
    This syntax is BooleanExpression?(Statement if BooleanExpression is true)Statement if BooleanExpression is false)
    You can nest the expression to create ElseIf conditions:
    Locals.PromptMessage=(Locals.LoopIndex==1?"string1"Locals.LoopIndex==2?"string2":"string3"))
    This means the same as:
    If Locals.LoopIndex=1 then
    Locals.PromptMessage = "string1"
    ElseIf Locals.LoopIndex=2 then
    Locals.PromptMessage = "string2"
    Else
    Locals.PromptMessage = "string3"
    End If
    I don't know if there is a limit to the nesting.
    Hope this helps.
    - tbob
    Inventor of the WORM Global

  • Search and replace all spaces between quotes with uderscore

    Hello,
    I'm new on Powershell and I'm trying to make the script that:
    searches over file and replaces all the spaces which have been found between quotes;
    removes all quotes (except these which has not value eg "").
    For example:
    Source file:
    string3=string4 string="string1 string2 string23" string8="" string5="string7 string8"
    Destination file:
    string3=string4 string=string1_string2_string23 string8="" string5=string7_string8
    I have been created script that searches the data correctly
    $file="c:\scripts\mk.txt"
    $data=Get-Content $file
    $1
    $regex = [regex]@'
    (?x) # ignore pattern whitespace option
    (?<test>(["'])(?:(?=(\\?))\2.)*?\1)
    $data |% {
    if ($_ -match $regex){
    new-object psobject -property @{
    test = $matches['test']
    }#when adding "|select-object test" I'm getting the correct data
    I have stopped here on search / replace operation (from space to underscore, and by removing the quotes leaving the empty quotes non touched). Can you help me to finish the script?
    Thanks!

    Try this.  It uses the [Regex] Replace static method, with a script block delegate:
    $file="c:\scripts\mk.txt"
    $data=Get-Content $file
    $regex = '(\S+=[^"\s]+)|(\S+="[^"]+")'
    $delegate = { $args[0].value.replace(' ','_') -replace '"(.+)"','$1' }
    $data |% { [regex]::Replace($_,$regex,$delegate) }
    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "

  • Easy way to create a list of strings in an object?

    I'm trying to create a HashSet of Strings but I don't want to have to add each string to the HashSet. There is a constructor for HashSet that allows you to give it a Collection. But how can I create a Collection of String other than having to add each string? Can I just :
    HashSet hs = new HashSet("String1", "String2", "String3", "String4");
    ?

    This programming problem is as old as the hills, and there are a zillion ways to do it. One of the simplest is by using String.split. Example:   String separator = "[^\\w]+";
       String string = "I think, therefore I am; or maybe not. What do you think?";
       String[] array = string.split(separator);
       System.out.println("String    : \"" + string + "\"");
       System.out.println("Word count: " + array.length + " words.");The key is the String separator. This is what is known as a "regular expression." It looks pretty obtuse (and is); do some research on regular expressions to figure out it means.
    This example does not account for a few special cases, such as words split between lines with hyphens, and perhaps words enclosed in double quotes. That is left as an exercise for the reader.

  • How to use Special Characters in CONCAT function or another form with Xquer

    Hello everyone
    I'm using PS3 OEPE within message flow (proxy)and I'm using Xquery.
    I'm using the CONCAT function, but this does not allow me to concatenate special characters not allowed, for example:
    I want to concatenate these strings:
    String1 = “&amp;lt;get-person&amp;gt;&amp;lt;id-person&amp;;gt;”
    String2 = “123”
    String3 = “&amp;lt;/id-person&amp;;gt; &amp;lt;/get-person&amp;gt;”
    I want to represent characters regex. It means no XML characters
    Someone knows some way, any function that allows me to concatenate in OSB these values with Xquery?
    Edited by: chromosoma on Sep 5, 2012 5:59 PM

    Hi,
    It seems to me you're doing things in the most complicated way possible...
    Firstly, you should use codepoints-to-string not the reverse... Secondly, the function work with decimals, not hexa
    http://www.xqueryfunctions.com/xq/fn_codepoints-to-string.html
    http://www.xqueryfunctions.com/xq/fn_string-to-codepoints.html
    This works...
    concat(codepoints-to-string(38),'lt',codepoints-to-string(59),'get-person')But this also works... Note that I've inserted a space between the &amp; and the lt so the forum formatting can show it...
    let
    $String1 := "& lt;get-person& gt;& lt;id-person& gt;",
    $String2 := "123",
    $String3 := "& lt;/id-person& gt;& lt;/get-person& gt;"
    return
         concat($String1,$String2,$String3)And, finally this also works... So what's the reason for escaping &lt; and &gt; with &amp;lt and &amp;gt; and why codepoints?
    let
    $String1 := "<get-person><id-person>",
    $String2 := "123",
    $String3 := "</id-person></get-person>"
    return
         concat($String1,$String2,$String3)Cheers,
    Vlad

  • How do you search for a partial match in a vector table?

    Hi,
    I have a program that parses some table of mine into a vector table. It has a search function in the program that is intended to search the vector table for a specified keyword that the user enters. If a match is found, it returns true. If no match is found, false is returned.
    That part works great. However, I would like my program to search the vector table to try and find a PARTIAL match of the users entry, instead of looking for a complete match.
    Currently my program uses the Vector method 'contains(Object elem)' to find the complete matches and that part works great. It doesn't seem to work with partial matches. Either the exact syntax of the user's entry is in the table or it isn't.
    Hope I was clear enough. Any thoughts?
    Cheers,
    the sherlock

    You might find this code of interest. It uses the same commands as mentioned previously, but wraps them into a Comparator object. Note that you can't store elements with '*' in the Vector 'v' and that you must sort the elements with Collections.sort() beforehand.
    import java.util.*;
    class WildcardComparator implements Comparator
        public int compare(Object o1, Object o2)
         String string1 = (String)o1;
         String string2 = (String)o2;
         if(string2.indexOf("*") != -1) {
             // take off asterik
             return wildcardCompare(string1,
                           string2.substring(0, string2.length()-1));
         return string1.compareTo(string2);
        public int wildcardCompare(String s1, String key_s) {
         String s1substring = s1.substring(0, key_s.length());
         return s1substring.compareTo(key_s);
    public class wildcard
        public static void main(String[] args)
         Vector v = new Vector();
         v.add("coke");
         v.add("pepsi");
         v.add("7-up");
         v.add("a&w root beer");
         v.add("a&w cream");
         Collections.sort(v, new WildcardComparator());
         String key = "a&w*";
         int index = Collections.binarySearch(v,
                                  key,
                                  new WildcardComparator());
         if(index > 0)
             System.out.println("elem: " + v.get(index));
         else
             System.out.println("item not found");
         key = "c*";
         index = Collections.binarySearch(v,
                                  key,
                                  new WildcardComparator());
         if(index > 0)
             System.out.println("elem: " + v.get(index));
         else
             System.out.println("item not found");
    }

  • Error Reading from a File

    Right now i am coding a game and i need to read from a text file to load the map. The only problem is that i cant do this in internet exploerer because i get an error saying that access is denied. I've been researchign the problem nonstop and the only solution i have found is to sign the applet, but i dont even know how to do that. I would like to avoid having a signed applet for obvious reasons and i'm sure its possible to do it without a signed applet. My code is as follows:
              try{
                   BufferedReader in = new BufferedReader(new FileReader("Map1.txt"));
                   String input, string1, string2;
                   for (int x = 0; x < terrain.length; x++){
                        terrain[x].setFilled(false);
                   for (int x = 0, currentArray; x < terrain.length; x++){
                        if ((input = in.readLine()) != null) {
                             StringTokenizer st = new StringTokenizer(input);
                             currentArray = Integer.parseInt(st.nextToken());
                             terrain[currentArray].setTerrainType(st.nextToken());
                             terrain[currentArray].setFilled(true);
                        else{
                             break;
                   in.close();
                   offscreenMap = createImage(size().width, size().height);
                   mapGraphics = offscreenMap.getGraphics();
                   mapGraphics.clearRect(0, 0, size().width, size().height);
                   // everything from here down is to be painted to mapGraphics... but it doesn't get this far cuz of an error
                   for (int x = 0; x < terrain.length; x++){
                        if (terrain[x].getTerrainType().equals("Grass")){
                             grass.paintIcon(this, mapGraphics, terrain[x].getX(), terrain[x].getY());
                             System.out.println("terrain(" + x + ") is Grass");
                        else if (terrain[x].getTerrainType().equals("Tree")){
                             tree.paintIcon(this, mapGraphics, terrain[x].getX(), terrain[x].getY());
                             System.out.println("terrain(" + x + ") is Tree");
                        else if (terrain[x].getTerrainType().equals("Mountain")){
                             mountain.paintIcon(this, mapGraphics, terrain[x].getX(), terrain[x].getY());
                             System.out.println("terrain(" + x + ") is Mountain");
              catch (FileNotFoundException e){
                   System.out.println("Map not found");
              catch (IOException e){
                   System.out.println("IOException Error!");
              }Please tell me how i could read from the same file with a BufferedReader without having to sign an applet.
    Thanks for your help!!!

    ignore that one comment about something not working, thats a thing of the past (offscreen graphics problem, fixed by moving createImage() outside of the contructor) :-D

  • Can we use receiver enhancement feature for a web service scenario?

    Hi Experts,
    We have to send across an invoice to web service enabled legacy system from ECC.
    ECC>ABAP Proxy>SAP PI>SOAP Adapter>Legacy System1
    ECC>ABAP Proxy>SAP PI>SOAP Adapter>Legacy System2
    Requirement is like if the invoice number starts with 1A, it should go to Legacy System1 & if the invoice number starts with 2A, it should go to Legacy System2.
    Can we do it in one single scenario using receiver enhancement and if yes How?
    Regards
    Nidhi Kukreja

    You can make use of the XPATH function starts-with(string1,string2) and customize your condition as shown in this blog:
    /people/shabarish.vijayakumar/blog/2006/06/07/customise-your-xpath-expressions-in-receiver-determination
    Update:
    It can even be done without using any XPATH function.....just make use of the option Contains Pattern from the dropdown available for the Middle Operand....right operand will be 1A*
    Regards,
    Abhishek.
    Edited by: abhishek salvi on Feb 3, 2010 1:00 PM

Maybe you are looking for