Assignment question

Consider two versions of the same Java source :
Version 1
public class char1 {
public static void main(String a[]) {
char y=65;
System.out.println("Value a : " + (y+1));
System.out.println((char)(y+1));
java char1
Value a : 66
B
Version 2
public class char1 {
public static void main(String a[]) {
int y=65;
System.out.println("Value a : " + (y+1));
System.out.println((char)(y+1));
java char1
Value a : 66
B
How is possible to assign an integer to a character ? Can anyone explain
TIA,
Ora Labora.

You are on the right track DevMentee, this should make it clearer:
int is a 32 bit quantity
char is a 16 bit quantity (Unicode characters take up 2 bytes)
it's because when you say char c= 65;, the compiler
knows it is a constant and the value can fit into a
char.....Any non-fraction constant number is treated as a 32 bit java int, this should have resulted in a narrowing conversion error, but it did not because Java relaxes the conversion checks for integer constants.
when you do
int a = 65;
char c = a;
the value of a can change and may be too big to fitWhether the value of a can change / changes etc. is immeterial because, the compiler reasons that squeezing a 32 quantity into a 16 bit space is not a good idea.
into a char so compiler complains....this is called
narrowing conversion and you need to do an explicit
cast to inform the compiler that you know what you are
doing...
e.g.
char c = (int)a;Yup, this would work because you are essentially telling the compiler "I know what I am doing"... if u messed up, then it is your problem :) ... The most signifcant 16 bits are thrown away and the lower 16 bits are stored... the value 65 comfortably fits into this space, so there are no problems :)

Similar Messages

  • Organisation Assignment Questions

    Hi ALL,
    Currently, I am developing an application which allows BP to assign themselves assigned to the position with relationship “Owner” under an organization unit.just like how you work in transaction: PPOSA_CRM
    When create this relationship, I have found two function modules which are from different function groups
    RHOM_MAINTAIN_RELATION_BUFF
    This function module is for Organization Management.
    2.     RH_Relation_maintain
    This is like for Personal Development.
    Here come my questions:
    ·     When I used “RHOM_MAINTAIN_RELATION_BUFF” to create the relationship, the relationship can be created in the buffer, however, when I call function Module “RHOM_WRITE_BUFFER_TO_DB” to update database afterwards, the database update doesn’t work.
    Anybody have any idea about it?
    ·     Since I failed to update database, I tried to create relationship between Position and BP by FM “RH_Relation_maintain”, However, I have got an exception that saying “B270”(relationship type-Owner) is not allowed between Position(object type-s ) and Business Partner (object type BP), check table T777E.
    I checked the table, this relationship doesn’t exit in T777E between “S” and “BP”, however, when I checked table T77AW, there “b270” exist for BP and position.
    Can I use this Function module “RH_Relation_maintain” to create relationship between BP and position? How to use this relationshi type in this FM?
    Many Many Thanks,
    Heather

    Hi Heather,
    i'm using following function modules to maintain infotype 1000. They should also
    work for it 1001:
      CALL FUNCTION 'RH_CUT_OBJECT'
        EXPORTING
    *   LOAD                     = 'X'
          gdate                    = l_newendda
          histo                    = ' '
          gstat                    = '1'
    *   INVERT                   = 'X'
          vtask                    = 'B'
    *   ORDER_FLG                = 'X'
        commit_flg               = ' '
        authy                    = ' '
    *   PPPAR_IMP                =
    *   CUT_DEPENDENTS           = 'X'
    *   KEEP_LUPD                =
    *   WORKF_ACTV               = 'X'
        TABLES
          i1000                    = ltbl_p1000_abg
    *   ILFCODE                  =
       EXCEPTIONS
         error_during_cut         = 1
         no_authorization         = 2
         gdate_before_begda       = 3
         corr_exit                = 4
         OTHERS                   = 5
          CALL FUNCTION 'RH_INSERT_INFTY'
            EXPORTING
    *   FCODE                     = 'INSE'
              vtask                     = 'B'
    *   ORDER_FLG                 = 'X'
          commit_flg                = ' '
          authy                     = ' '
    *   PPPAR_IMP                 =
    *   OLD_TABNR                 = ' '
    *   REPID                     = ' '
    *   FORM                      = ' '
    *   KEEP_LUPD                 =
    *   WORKF_ACTV                = 'X'
            TABLES
              innnn                     = ltbl_p1000_upd
    *   ILFCODE                   =
       EXCEPTIONS
         no_authorization          = 1
         error_during_insert       = 2
         repid_form_initial        = 3
         corr_exit                 = 4
         begda_greater_endda       = 5
         OTHERS                    = 6
          CALL FUNCTION 'RH_UPDATE_INFTY'
            EXPORTING
              vtask                     = 'B'
    *         ORDER_FLG                 = 'X'
             commit_flg                = ' '
             authy                     = ' '
    *         PPPAR_IMP                 =
    *         OLD_TABNR_NEW_LANGU       = ' '
    *         REPID                     = ' '
    *         FORM                      = ' '
    *         KEEP_LUPD                 =
    *         WORKF_ACTV                = 'X'
            TABLES
              innnn                     = ltbl_p1000_upd
    *         ILFCODE                   =
           EXCEPTIONS
             error_during_update       = 1
             no_authorization          = 2
             repid_form_initial        = 3
             corr_exit                 = 4
             OTHERS                    = 5
        CALL FUNCTION 'RH_UPDATE_DATABASE'
          EXPORTING
            vtask              = 'D'
    *     BUFFER_UPD         = ' '
    *     ORDER_FLG          = 'X'
    *     COMMIT_FLG         = 'X'
    *     CLEAR_BUFFER       = 'X'
    *     KEEP_LUPD          =
    *     WORKF_ACTV         = 'X'
         EXCEPTIONS
           corr_exit          = 1
           OTHERS             = 2
    Regards
    Bernd

  • Controller Assignment Question

    Hello, i was wondering if anyone could steer my in the right direction on this problem I have with controller assignments. See, i want to use Logic 7.1 on my Powerbook in a live situation with some midi controller knobs. The question is, how can i set up controller assignments so that i can have different assignments per song ( which has totally different tracks and plugins) ? I broke out the manual and read something about modes and zones, but cannot figure this out for the life of me, or know if this is the right direction to go in.
    I create the controller assignments for one song, then when i open up the next song, they seem to be interfering with each other. I suppose the controller function isnt particularly meant for this, but is there any way i can get around this problem?
    Thank you for taking the time to read this! I really appreciate any help.
    Leech.
    http:/www.myspace.com/leechernowetz
    Powerbook g4   Mac OS X (10.4.6)   Logic 7.1 , Evolution X-Session MIDI Interface

    When you use the "Learn mode", you bypass the Enviornment all together and Logic directly maps the controller info to the AU plug-in (or other control parameter).
    A quick and dirty way to (maybe) resolve this would be to make your midi controller send different channels on for each song. Therefore, song 1 would respond to assigned midi key commands on channel 1, song 2 would listen for channel 2, etc...I don't have Logic in front of me, but I think this might work. It's not the most elegant solution, but it might work. Another similar idea would be to put a transformer and shift all your CC different values (e.g. song 1, CC#1 would be CC#21 for song 2, CC#2 on song 1 would be CC#22 on song 2). And if you want to contol the same parameter from song to song, don't transform the CC (this is obvious, but I want to point it out).
    To reiterate, this is not the most elegant solution and I could be completely wrong, but this might be a quick fix.
    The best way (in my opinion) is wire cables (with transformers) in the environment to the audio object that you want to control. I haven't been able to get that idea to completely work and I am still working on it.
    good luck.
    Dual 1.8Ghz G5 PB G4 1Ghz LP7.1.1 RME FF800   Mac OS X (10.4.6)   Reaktor 5.1 Reason 3.0.4 Live 5.0.2 Battery 2.1.1 Recycle 2.1 DFH 1.5.3

  • External DL DVD Burner Assignment Question

    Hi, I have an external LaCie Dual Layer DVD burner and an internal (Sony) SuperDrive that is NOT a DL drive. Using the LaCie patch I can use the LaCie DL burner with iDVD, but I can't control which drive iDVD will choose on any given project. One time when I go to burn the project iDVD chooses the DL drive and sometimes it chooses the internal drive.
    My question is, how can I assign iDVD to use a particular drive, and then if I can assign it to use the DL external drive, then will it let me burn a project that is over 2 hours? I question this because it still sees a single layer SuperDrive in the G5.
    Can anyone provide me with some guidance please? Yes, I've already tried PatchBurn with no luck.
    Thanks in advance. --Jim

    Hi Jim,
    My question is, how can I assign iDVD to use a particular drive, and then if I can assign it to use the DL external drive, then will it let me burn a project that is over 2 hours? I question this because it still sees a single layer SuperDrive in the G5.iDVD does not support selection of DVD burners, you cannot assign which DVD burner to use. In order to use your 'non-Apple' DL burner for DL project. You need a French Patch, there are several threads on this subject:
    Topic: iDVD & external drive dual layer
    Topic: double layer dvd
    Topic: Dual-Layer Disc Image
    Topic: Double Layer?
    Power Mac G4 (QuickSilver)   Mac OS X (10.4.3)  

  • ArrayStack --- Assignment question

    Hi guys,
    Ive been given a question, where i have to have the user enter a sentence into the application. And then displays the reverse of the sentence within the console... Any ideas what way i have to go about doing this?..
    T.I.A
    Stefan

    - Learn the fundamentals of Java. In particular, arrays and method calls.
    - Study up on recursion or whatever CS concept you were supposed to have learned that this assignment is testing and reinforcing.
    - Figure out the steps to solve this problem using that CS concept, but without regard to Java. Write those steps down in English and/or pseudocode.
    - Read this: http://home.earthlink.net/~patricia_shanahan/beginner.html

  • PD appraisal assignment Question

    Hi All,
    I have question in PD-
    1.how can we assign to the created appraisal models to the all employees or employees groups?
    2.Can we assign the Appraisal models to the Org Units?
    Thanks!
    Seema

    when i tried to create templet-Goto OOAM -> Right Click Personnel Appraisals -> Create Category then Right Click the Category -> Create Template
    But when i goto ooam i got appraisal catalog/model details not personnel appraisal details?
    how to create appraisal templet in this situation?
    can u explain in brief?

  • Threaded Sudoku solver - Assignment question (NOT LOOKING FOR ANSWERS  )

    Hi All,
    I'm going to be upfront and point out this is an assignment that i'm currently working on and i'm not receiving much in the way of feedback from the class forums.
    This is currently a 4th year OO assignment for UNSW Australia.
    What I am having trouble doing is figuring out where my program is deadlocking or dying. There have been a number of requirements set out by the assignment, basically no synchronization, no locking. We are able to use volatile, atomic, immutable and thread-local objects. The task is to find all solution for a given N x N sudoku problem using X number of threads. I have successfully built the solver (X = 0) without too much trouble and I thought i had managed to modify the recursive algorithm to suit but unfortunately I think I have come unstuck.
    Any generalized tips would be appreciated when implementing threads that utilise checking flags to determine when the thread is finished processing.
    Kind Regards,
    Chris Gibbs

    Honestly, I think that recursion (as you stated) would be the easiest way to have solved this problem. But as you stated, threads must be used to solve this problem as a requirement of the project...
    You could easily launch a Thread each time instead of calling your recursive method... that could possibly result in a crap load of threads, but the idea would work.
    Definitely take a look at the SwingWorker class here if you're able to use J2SE 6: [http://java.sun.com/javase/6/docs/api/javax/swing/SwingWorker.html|http://java.sun.com/javase/6/docs/api/javax/swing/SwingWorker.html]
    I currently use it while gathering data from several websites at the same time. What I did was create and execute() X number of MySwingWorker objects to collect the data, while they are not complete (i.e. MySwingWorker.isDone() is false) I just Thread.sleep(...).
    Give it a try. It may suit your needs.

  • Dynamic Channel Assignment Question

    I have a WLC 4400, and I have discovered that some areas, the access points are on the same channel. For example the floor have four access points, and the access points are working in this channels:
    AP01=channel 01
    AP02=channel 11
    AP03=channel 11
    AP04=channel 11
    If Dynamic Channel Assignment is enable in the controller, Why the access points are on the same channel?
    The access points are near each other.
    WLC4400 System version 6.0
    Any suggestion?
    Is better manual configuration?

    Hi Nicolas I have this situation:
    AP Name.......................................... AP22
    MAC Address...................................... 00:1d:a1:zz:yy:xx
      Radio Type..................................... RADIO_TYPE_80211b/g
      Radar Information
          Recommended Best Channel..................... 1
      Nearby APs
        AP AP53 slot 0..................  -67 dBm on   1 ()
        AP AP12 slot 0..................  -57 dBm on   6 ()
    The AP22 is working in the channel 1. ButI have another AP, in the same channel 1, this is normal operation?
    When a Nerby AP is considered away? when the dbm is -70, -71, -72 or -75, -74, -73 ??
    Thanks

  • Account assignment question (for subcontracting item category)

    Hello
    Is it possible to have a account assignment category with a consumption posting indicator V work with a subcontracting item category L?
    Our scenario is that a SD item category TAB auto generates a Subcontracting PO with account assignment M and item category L.
    The problem with account assignment M is that it references sales order, and does not propose BOM component material/quantity, like a standalone subcontracting movement (541 reference to PO)
    We want to issue components to the subcontractor referencing a PO, and maintain visibility thru ME2O (Which account assignment M wont allow).
    Is this possible ?
    I tried tweaking the account assignment category M by changing the consumption posting indicator to V.
    This allowed me to do the subcontracting issue 541 movement referencing a PO.
    However, I got 2 accounting errors at MIGO.
    No direct postings possible to G/L account 03-010
    I then changed the FS00 settings to allow direct postings, but got the next error and was stuck. I guess if these accounts are postable, my problem is solved but I don’t know how to do that!
    Acct. 03-010 for trans./event key BSX, postable directly
    If anyone is knowledgeable on account assignments or knows how I can solve these, I would greatly appreciate your input.
    Regards
    Ken

    Thanks for replying again, Gopala.
    Let me clarify, the SAP error I am receiving is at MIGO, following the successful transfer posting at MB1B (mtype 541 referencing the PO number. If I can get the proper account postings at MIGO (as in a standalone MM subcon scenario) here, my problem is resolved.
    When I hit post at MIGO (Finished Product mov type +101/Component reduction is -543 O) I receive the error "Acct. 03-010 for trans./event key BSX, postable directly " I then goto FS00 (G/L accounts) and uncheck the 'post automatically only' box. But then when I goto re-post at MIGO, I get the message
    "No direct postings possible to G/L account 03-010"
    So I am stuck in this circular error.
    Is this correctable?
    Thanks Again
    Ken

  • Object Assignment Question

    If the object planRightVO has the four level hierarchical structure
    planRightVO.getPayAdvRecord().getparticularRecord().setGroupNo("12345");
    planRightVO.getPayAdvRecord().getparticularRecord().getAdminUnit("A");
    planRightVO.getPayAdvRecord().getparticularRecord().getCertNo("00001");
    planRightVO.getPayAdvRecord().getparticularRecord().getAccountNo(1);
    When I assign
    PlanRightVO localPlanRightVO = planRightVO;
    will the localPlanRightVO has the same value under its hierarchical structure
    Thanks for help!
    Joe

    Regarding the use of Copy constructors:
    I haven't read the Effective Java book - but it sounds interesting and I'll certainly take a look. Perhaps it outlines a way to create copy constructors that addresses the problem that Bruce Eckel points out in "Thinking in Java".
    He says that on the surface, copy constructors seem like a good idea - but they don't work for Java.
    You can lose Object information:
    class Shape {
    public Shape(Shape s) {
    // copy
    public void printType() {
    System.out.println("Shape");
    class Circle extends Shape {
    public Circle(Circle c) {
    // call superclass copy constructor
    // copy
    public void printType() {
    System.out.println("Circle");
    class Test {
    void printShapeType(Shape s) {
    s.printType();
    Shape copy = new Shape(s);
    copy.printType();
    public final static void main(String args[]) {
    Circle c = new Circle();
    c.printType(); // prints "circle"
    printShapeType(c); // prints "circle", then "shape"
    So you are in effect down casting the Circle and losing it's 'circleness'. Using clone() will preserve the type.

  • Team assignment questions

    I was looking into doing team assignments for out projects that we have, and i just wanted to make sure that it was the best way to handle what we are trying to accomplish, since I have seen some posts that lead me to believe this may not be the best option.
    what I am trying to do is Assign each task to multiple people (only 1 of which has login credentials to PWA, the team leader/foreman).  I am hoping to get it so that he will only have to report updates on each task once for the whole group, and not
    once per team member (already made him the assignment owner for each person/generic resource).
    1) would making a team resource and assigning just that to the task be enough?  once all the people are assigned to that group that is.  it seemed like doing it this way, you would also have to deal with the work column yourself, since it is auto-calculated
    for just 1 resource and not the 3-4 you intended (might be best solution)
    2) if 1 is the right way to do it, are the resources assigned to the team able to be placed in other groups for other projects?  or are they stuck in that one until they are unassigned?  also, the team assignment groups are system wide, not just
    for each specific project?  for example, can i have (user 1, user 2, user 3)  and (user 1, user 4, user 5)?

    Hi Abhijit,
    Indeed as you stated, the team assignment can only be self-assigned. Meaning that a manager cannot assign a team assignment to another member. Customizing this feature could be quite complex and time/money consuming. If you decide to go that way, then it
    is out of my knowledge.
    Using the "reassign task" feature will not help because once reassigned, the manager will not be able to change the assignment again for another resource.
    I'd rather suggest to put in place a process together with the project manager who is actually managing assignments in the project with Project Pro. For example the manager can access the project plan and should only update his resources on assignments but
    not the project itself.
    Hope this helps,
    Guillaume Rouyre, MBA, MVP, P-Seller |

  • Workflow - Parameter Assignment Question

    I have this workflow where i have defined the input parameter in the "start" activity. and, have directly binded that parameter into the input parameter in the "mapping" activity.
    is this the right way to do? or do i need to assign the parameter (from "start" activity) first into a variable, and then assign it into the input parameter in the "mapping" activity?
    ~Prabha

    never mind, i got it :-)

  • Assignment Question with a DB

    Hi
    I have a mysql db.
    After executinf a select query, with returned resultset
    containing 2 columns, say date and x value,
    - how do I assign each row using jdbc
    to 2 independent arrays ?
    - how do I find out the row sizes (ie # rows retrieved)
    from the resultset ? cuz with that, then I could set
    the array sizes that are assigned by resultSet.
    Any help is appreciated.

    There is no good way to detemine the size of a ResultSet without a fair bit of work (looping through the ResultSet can be time-consuming on larger result queries, and requerying the database is always time-intensive). Also, requerying the database could lead to problems... if someone else inserts a row between when you run your "COUNT" query and when you run your real query, you're gonna have an ArrayIndexOutOfBoundsException if you try to use the count variable to create the arrays ahead of time.
    Using ArrayLists or Vectors, (or another datatype of that sort) usually works best for your situation. If you need to store multiple bits of information at each index, create another class that stores those variables (ie. name and date), and store those in the ArrayList.

  • Genre Assignment Question

    Is there a way to assign more than one genre to a single tune?

    pdmike wrote:
    Is there a way to assign more than one genre to a single tune?
    Yes. There is only one genre field, but you can put whatever you want in it. If you type "Rock, Pop, Reggae" (or even "rockpopreggae") it will match on "genre" "contains" "rock" or "genre" "contains" "pop" and, well, you get the idea.

  • DSP Assignment Question

    I have 2 fractional T1s (16 B-Channels), 4 BRIs and a 2-port FXO (I only plan to use one).  While adding the timeslots for the PRIs I ran out of DSPs so I had to steal some from XCode and CFB.  I now have only 4 XCode, 1 CFB, and no MTP configured on the router.  This is an MGCP gateway connected to CUCM 8.6.2.
    My question is, do I really even need hardware XCode and CFB if this is local to my CUCM?  Can't I just handle all the conferencing and transcoding on the server?

    It will depend on the number of codecs you define under the transcoder , the less codecs you define, more sessions you are able to configure. The total number of dsp's available on the router is the first consideration. A nice tool that you can use - DSP calculator
    http://www.cisco.com/web/applicat/dsprecal/dsp_calc.html?utm_source=twitterfeed&utm_medium=twitter
    Let me know if this answers your queries.
    Manish

Maybe you are looking for

  • Send variable from vision builder to NXT Brick

    Hello, I have a color sorting machine controlled by an NXT Mindstorms brick. I believe that Labview has a module to communicate with the Lego brick, but I was wondering if the Vision Builder (which we are currently using for another application) coul

  • Primary Contact

    Hi All, I am trying to design a report in which i need to pull the field where Primary Contact not equals to null in the activity subject area. But while doing so i can see Primary Contact as an Object within Account Object, where(in Primary Contact

  • Volume Manager

    We are connecting a Sun 3500 to an HP VA7400 storage device, we require redundant paths to our volumes and it has been suggested that we need to purchase Veritas Logical Volume Manager, can we accomplish the above using Solstice Disk Manager? Any adv

  • Creative Suite Color Setting

    I have Adobe CS6. When I go to my Adobe Bridge's Creative Suite Color Setting (under Edit Menu), it says "Suite Color Management is not enabled, Suite Color Management Requires a qualifying product launched at least once to enable this feature." I op

  • Colour cast on a MG 5300

    When I print out a black and white photo on my Canon Pixma MG 5300 I am getting a strong red colour cast. Have tried all I know to correct it to no avail so any help would be great!