Comparing to char variables

I want to see if:
char theSquare==("g");
is this possible?
I'm getting errors so that my program won't compile.
I read in a char and store it in theSquare and I want to see what letter it is. It won't let me use .compareTo() or .equals() either for some reason. Please Help.

char c = 'g';
if (c == 'g') {
do statements
else { do statements }

Similar Messages

  • How to store serval char variables into a string variable?

    I have serval char variables, but i don't know how to put them together (without using arrays). I am thinking to store these char variables into a string variable but i don't know how to do it. For example,
    char letter1 = 'a', letter2 = 'b', letter3 = 'c';
    String letters;
    then how can i do to make letters = "abc" from using letter1,2,3?
    I am just a beginner of Java, if anyone can help me, i will appreciate that very much!!!

    String letters=""+leter1+letter2+letter3;is fine and dandy. What it actually compiles to is
    String letters = new StringBuffer().append(letter1).append(letter2).append(letter3).toString();Which ofcourse is much more code to write, but still good to know.
    So do see the API for java.lang.StringBuffer.
    Heikki

  • How to get a "char variable" with presentation variable???

    I want to pass a char variable with presentation variable, I don't have problems if I pass "int".
    For example in answers page I add a column that contains years of my dimension. 2000 until 2012 and prompted my presentation variable "year" (from my dashboard prompt) and when I go to dashboard if I choose in my prompt 2006 in my report appear 2006...any problem and easy. But my problem is if I would pass a char variable, in my prompt also I have months but not numbers else names: January, February, March...and a presentation variable that name is "month". If I do the same report but change column year to month (name) I don't have any results and I have an error.
    How can I solucionate this???
    Thank you!!

    Alex,
    Do you have separate columns for Year and Month Name. If Yes, Then why it is so confusing?
    1. create a dashboard prompt with month name column
    2. Assign it to monthname variable
    3. In your report use above variable any where.., but what ever you are doing should be logical and valid to get some data.
    In general above approach will work.
    You said, "No! I don't want to do a filter with month! I would like to pass this variable, in this example don't make sense but I need to pass a char variable with presentation variable to do another things..."
    what does that mean, what you are trying to do with the variable in your report. If you give a example that would be better.
    - Madan

  • How to convert DATE variable to CHAR variable

    dear all,
    How to convert DATE variable to CHAR variable
    thanq

    Depending on your final goal here are 2 options.
    DATA: datein        TYPE d.
    DATA: dateout(10)   TYPE c.
    DATA: dateout2(8)   TYPE c.
    datein = sy-datum.
    WRITE datein TO dateout MM/DD/YYYY.
    dateout2 = datein.
    WRITE:/ datein, dateout, dateout2.
    and the output
    05022008 05/02/2008 20080502    

  • Comparing Previous shared variable to current variable Whileprintingrecords

    Hi All,
    I have a report with items listed in the footer. I need to compare the shared variables of 1 record to the next but I can't use Previous(field) because I'm doing the comparisons in the footer. How can I use Shared variables to find duplicate values? In some kind of WhilePrintingRecords Array? If so, how do I limit the array to compare the present value to the previous value only?
    footer row     SharedVariable    
    1                    887768
    2                    887756
    3                    887756
    4                    887787
    Thanks,
    John

    Hi John,
    Create a formula with a code that looks something like this and place it in the footer section(by the way, which footer are you taking about?):
    WhilePrintingRecords;
    numbervar array arr;
    numbervar x;
    shared <variable_datatype> <variable_name>;
    if Not(variable_name IN arr) then
         x := x + 1;
         redim preserve arr[x];
         arr[x] = variable_name;
    Create another formula to display the contents of the array and place this on a footer section below the above one:
    WhilePrintingRecords;
    numbervar array arr;
    stringvar vals;
    numbervar i;
    for i := 1 to ubound(arr) do
         vals := vals + arr[i] + chr(13);
    left(vals,len(vals)-1);
    Right-click this formula field once it's placed > Format field > Common tab > Check the 'Can Grow' option.
    Hope this helps.
    -Abhilash

  • Storing numbers in char variables.

    Hi All
    I need to store a number in a character variable
    Num =  686  (integer type)
    here c1 is the char variable of length 4.
    If I give C1 =  Num
    the value is not stored.
    How to store a number in a character variable.
    Regards
    Renuka.

    Works fine. run the code below.
    REPORT  ztest.
    DATA: n TYPE i VALUE '6666',
          c TYPE char4.
    c = n.
    BREAK-POINT.
    write: c , n.

  • Increment CHAR variable

    Hi,
    I'm a beginner in ABAP and I have a question..
    Is possible increment a char variable?
    for example I have varible:
    R001 and i want increment this variable till RZZZ..
    There is some solution or some function that i could use to do this?
    Thanks so much.

    Hi,
    please find starting & ending sequence numbers from R000 RZZZ
    000     001     002     003     004     005     006     007     008     009     00A     00B     00C     00D     00E     00F     00G     00H     00I     00J     00K     00L     00M     00N
    00O     00P     00Q     00R     00S     00T     00U     00V     00W     00X     00Y     00Z     010     011     012     013     014     015     016     017     018     019     020     021
    022     023     024     025     026     027     028     029     030     031     032     033     034     035     036     037     038     039     040     041     042     043     044     045
    046     047     048     049     050     051     052     053     054     055     056     057     058     059     060     061     062     063     064     065     066     067     068     069
    070     071     072     073     074     075     076     077     078     079     080     081     082     083     084     085     086     087     088     089     090     091     092     093
    094     095     096     097     098     099     01A     01B     01C     01D     01E     01F     01G     01H     01I     01J     01K     01L     01M     01N     01O     01P     01Q     01R
    01S     01T     01U     01V     01W     01X     01Y     01Z     02A     02B     02C     02D     02E     02F     02G     02H     02I     02J     02K     02L     02M     02N     02O     02P
    ZUM     ZUN     ZUO     ZUP     ZUQ     ZUR     ZUS     ZUT     ZUU     ZUV     ZUW     ZUX     ZUY     ZUZ     ZVA     ZVB     ZVC     ZVD     ZVE     ZVF     ZVG     ZVH     ZVI     ZVJ
    ZVK     ZVL     ZVM     ZVN     ZVO     ZVP     ZVQ     ZVR     ZVS     ZVT     ZVU     ZVV     ZVW     ZVX     ZVY     ZVZ     ZWA     ZWB     ZWC     ZWD     ZWE     ZWF     ZWG     ZWH
    ZWI     ZWJ     ZWK     ZWL     ZWM     ZWN     ZWO     ZWP     ZWQ     ZWR     ZWS     ZWT     ZWU     ZWV     ZWW     ZWX     ZWY     ZWZ     ZXA     ZXB     ZXC     ZXD     ZXE     ZXF
    ZXG     ZXH     ZXI     ZXJ     ZXK     ZXL     ZXM     ZXN     ZXO     ZXP     ZXQ     ZXR     ZXS     ZXT     ZXU     ZXV     ZXW     ZXX     ZXY     ZXZ     ZYA     ZYB     ZYC     ZYD
    ZYE     ZYF     ZYG     ZYH     ZYI     ZYJ     ZYK     ZYL     ZYM     ZYN     ZYO     ZYP     ZYQ     ZYR     ZYS     ZYT     ZYU     ZYV     ZYW     ZYX     ZYY     ZYZ     ZZA     ZZB
    ZZC     ZZD     ZZE     ZZF     ZZG     ZZH     ZZI     ZZJ     ZZK     ZZL     ZZM     ZZN     ZZO     ZZP     ZZQ     ZZR     ZZS     ZZT     ZZU     ZZV     ZZW     ZZX     ZZY     ZZZ
    My suggestion will be create a custom table and keep all possible combination numbers in it and use this table

  • Can you help me compare two chars?

    I keep getting a 'cannt be dereferenced' error whenever I try compareing two chars. What exactly does this mean? Here's the code I'm useing:
    import java.io.*;
    public class Replace
       public static void main(String[] args)
          char let = 'h';
          char let2 = 'i';
          int temp = let.compareTo(let2);
    }

    Thank you slappy for trying to make me leaern. In
    future, try to give a little background to wwhat your
    explaining. As you can see, I was useing character
    methods on a char, and your reply just plain confused
    me!Sir,
    I know it confused you. But I did say HINT. And I did say char and Character and I was hoping that would twig. For your future reference in Java pimitives are lower case while Class Names Begin With A Capital Letter.
    Well good luck.
    Sincerely,
    Slappy

  • Compare two complex variables with BPEL ?

    Hi,
    I would like to compare 2 csv files with BPEL, with specific rules. For example, I would like to check that for each row : "Value of Field1 of File1" has less than a 10% difference with "Value of Field1 of File2"
    I can successfully retrieve the content of the files, thanks to the following thread : Help! Three questions about FileAdapater. . Now the files are in 2 variables.
    What is the right method to compare the variables, row by row with this kind of specific validation rules ? Should I handle it with a Java call ? Especially, where should be the loop on rows : in BPEL (if so : how ?) or Java ?
    Regards,
    Alexandre
    Message was edited by:
    Alexandre

    I suggest having a look at the Array sample (orabpel\samples\tutorials\112.Arrays)
    that shows how to loop through an array.
    Whether to do this in BPEL of Java depends on a lot of circumstances, but I suggest giving this a try first.

  • Compare two dynamic variables

    Hello,
    I'm struggeling comparing two variables against each other as seen below. I have some AD-group names in a csv file, and I have a  variable($getGroup) with results from a Get-ADGrup-query.
    I'd like to filter out the groups of the csv-file from the variable, so "$getGroup" in this example should end up empty. 
    In the example below, the return is the two groups, so it doesn't get filtered out. How can I do that?
    Contents of exclude.csv:
    Name,Comment
    "AD,Group1","Some comment"
    "AD*Group2","Some comment"
    $excluded = Import-CSV 'C:\temp\exclude.csv'
    $getGroup = Get-ADGroup -Filter * | Where-Object {$_.Name -like '*,*' -or $_.Name -like '*#*' -or $_.Name -like '*+*' -or $_.Name -like '*"*' -or $_.Name -like '*\*' -or $_.Name -like '*<*' -or $_.Name -like '*>*' -or $_.Name -like '*;*'}
    #At this point $getGroup returns two groups; AD,Group1 and AD*Group2
    $getGroup = $getGroup | Where-Object {$_.Name -notlike $excluded.Name}
    $getGroup

    Hi,
    If you have actual group names in your input CSV, try this:
    $excludedGroups = Import-Csv .\excludeGroups.csv | Select -ExpandProperty Name
    Get-ADGroup -Filter * -SearchBase 'OU=Testing,DC=domain,DC=com' |
    Where { $excludedGroups -notcontains $_.Name }
    Don't retire TechNet! -
    (Don't give up yet - 13,085+ strong and growing)

  • Cannot resolve symbol on char variable

    my compiler stops at this line
    char variablename = keyboardInputChar();
    i am trying to input a character and declare a variable at the same time.
    what am i doing wrong?
    any help appreciated.

    my compiler stops at this line
    char variablename = keyboardInputChar();Well, variable 'variablename' can definitely be resolved, because your defining it there; I think your compiler can't find method 'keyboardInputChar()' anywhere. Have you defined that method in the same class?
    kind regards

  • Compare individual char of 2 string

    Hi
    I need to compare the each individual char of 2 string.
    String a = "Ae12";
    String b = "aE12";
    // I tried the followings:
    // a
    String c = a.substring(0,0);
    String d = a.substring(1,1);
    String e = a.substring(2,2);
    String f = a.substring(3,3);
    // b
    String c1 = b.substring(0,0);
    String d1 = b.substring(1,1);
    String e1 = b.substring(2,2);
    String f1 = b.substring(3,3);
    if(c.equalsIgnoreCase(c1)&&d.equalsIgnoreCase(d1)&&e.equalsIgnoreCase(e1)&&f.equalsIgnoreCase(f1)) // Cannot be compared
    // and I tried the followings:
    // a
    char c = a.charAt(0);
    char d = a.charAt(1);
    char e = a.charAt(2);
    char f = a.charAt(3);
    // b
    char c1 = b.charAt(0);
    char d1 = b.charAt(1);
    char e1 = b.charAt(2);
    char f1 = b.charAt(3);
    if(c==c1&&d==d1&&e==e1&&f==f1) // cannot be compared.
    Both cases cannot be compared. How can I fix it?
    Because I want to compare those 2 strings without case sensitive and numbers.
    Thanks

    techissue2008 wrote:
    String a = "Ae12";
    String b = "aE12";
    Then, are "Ae12" and "aE12" the same when ignore case?
    If so, the Strings are actually the same.No, the Strings are not the same, if by same, you mean the "same" Object, or the "same" value when case is not ignored, but they are the "same" value when case is ignored.
    This prints true (try it yourself), as it should
    public class Test {
      public static void main (String[] args) {
        System.out.println("aE12".equalsIgnoreCase("Ae12"));
    }They are still two distinct instances with two distinct values however, so where, exactly, is your problem?

  • Problem in comparing a character variable to date value.

    Hi All,
                 I have a scenario where I am comparing a variable of type c with a database field which is a date.Now the comparison is failing though it should not.I can't change the variable because I am capturing that from Line selection ie through get cursor.
    So is there any FM or any other way through which i can change this value to database field value type.
    Also variable has date in format 17.12.207 where as in table it is stored as 20071217 i.e YYYYMMDD.
    Thanks in Advance,
    Saket.

    Hi saket,
    Use  as the code below;
    data : chr_date(10) type c value '12.12.2007'.
    data : lf_date type d.
    CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
      EXPORTING
        date_external                  = chr_date
    IMPORTING
       DATE_INTERNAL                  = lf_date.
    Now you can compare lf_date with database date field.
    Revert back if u have any doubts.
    Regards
    Karthik D
    Edited by: Karthik D on Sep 20, 2008 7:53 PM

  • How do i compare value javascript variable with jsp variable

    I have promblem .I have variable that store store the attribute value of column .The colum has more then one value.How to i compare with javascript value .Currently I am using the following method .
    <%String sql_query3 = "SELECT DISTINCT (ir_tran_typ),ir_rea_desc "+
                                              "  FROM intrcd "+
                                              " GROUP BY ir_tran_typ ";
                               System.out.println("trans type"+sql_query3 );           
                                try{
                                    rset = db.execSQL(sql_query3);
                                catch(SQLException e) {
                                    System.err.println("Error in query - intrcd - transaction_main.jsp " +e +" sql " +sql_query3);
                                while(rset.next()== true){
                                    tran_cde = rset.getString("ir_tran_typ");
                                            rea_desc = rset.getString("ir_rea_desc");%>
                                            <%System.out.println("trans type 34 "+tran_cde );%>
                                                 //tran_typ = addElement('<%=tran_cde%>');
                                                 <% }%>
                                      if(obj.value== '<%=tran_cde%>' ){      
    <%                                 String sql_query2 = "SELECT ir_rea_cde,ir_rea_desc"+
                                              "  FROM intrcd"+
                                              " WHERE ir_tran_typ = '"+tran_cde+"' " +
                                                        " ORDER BY ir_rea_cde ";
                               System.out.println("trans type"+ tran_cde);           
                                try{
                                    rset = db.execSQL(sql_query2);
                                catch(SQLException e) {
                                    System.err.println("Error in query - emmast2 - transaction_main.jsp " +e +" sql " +sql_query2);
                                        index = 1;
                                while(rset.next()== true){%>
                                document.all.rea_cde.options[<%=index%>] = new Option(eval('"<%=rset.getString("ir_rea_cde")%>"'));
                                document.all.rea_cde.options[<%=index%>].value = eval('"<%=rset.getString("ir_rea_cde")%>"');
                                document.all.rea_cde.options[<%=index%>].text = eval('"<%=rset.getString("ir_rea_desc")%>"');
    <%                          index++;
                                       }%>
    please replay me soon
    thank you.

    javascript and java do not mix.
    Java code runs, and produces HTML/javascript.
    Java code stops running.
    The page loads in the browser, and it starts up javascript.
    Javascript cannot talk to java and vice versa.
    Your JSP can generate javascript code onto the page to be executed on the client, but they never directly communicate.
    please replay me soongame over dude ;-)

  • Increment a Char Variable

    How do you increment a character variable?
    Eg.
    DATA: L_VAR1(3) TYPE C,
              L_INC(3) TYPE C.
    L_VAR1 = '080'
    L_INC = '001'.
    Then I need in a particular Loop run, L_VAR1 to vary from 080, 081, 082...120.
    If I increment it with L_VAR1 = L_VAR1 + L_INC.
    The next value stored is 81 and not 081.
    Please provide Inputs in2 this.
    Thanks

    Hi..
    Since u need a numeric value. Declare with Type N.
    Eg:
    DATA: L_VAR1(3) TYPE N,
    L_INC(3) TYPE N.
    L_VAR1 = '080'
    L_INC = '001'.
    Then:
    L_VAR1 = L_VAR1 + L_INC.  "This will work.
    <b>
    REWARD IF HELPFUL.</b>

Maybe you are looking for

  • NSM Engine Start and Stops

    I have installed NSM 3.0.4.4 on a SLES 11 SP1, OES 11 SP1. After doing battle with certificates and other issues, I had finally got it up and running. The problem comes when I attempt to complete the migration process from the previous Netware server

  • Premiere CC crashes when I try to export

    I have the macbook OS X version 10.8.3 and am using the Premiere Pro CC version 7.2.1. I have rendered my sequence and I am attempting to export it to put it on youtube. I click 'Export' and then on 'Media' and then a message pops up saying "Sorry, a

  • Weblogic for Redhat Linux 5

    I am new in weblogic . During the configuration, it let me to select development mode and production mode. What's the different between the 2 mode? Thanks.

  • Remote speaker not compatible

    So I just tried to use iTunes to stream music to my remote speaker, which I've had connected and been using without problems for many years. I have upgraded to iTunes 7.2, but I did this awhile ago. Nevertheless, I got the following error message whe

  • No network connection after recent update

    I have a Droid Razr and I just updated it today (Mar. 20,2013) and i have no 3G connection at all. Im not able to send or receive picture messages or get into My Verizon Mobile. I have three gray bars and thats it. Please HELP!