Why is the answer of the program such??

I have a program code below.
class Flag
private boolean flag;
public Flag() {
boolean flag = true;
public boolean getFlag() {
return flag;
public static void main(String[] args) {
Flag f = new Flag();
System.out.println(f.getFlag());
When i run the program the output is false. I don't understand why? can anyone explain to me? Thanks

I have a program code below.
class Flag
private boolean flag;
public Flag() {
boolean flag = true;
public boolean getFlag() {
return flag;
public static void main(String[] args) {
Flag f = new Flag();
System.out.println(f.getFlag());
When i run the program the output is false. I don't
understand why? can anyone explain to me? ThanksThe correct one is:
class Flag
   private boolean flag;
   public Flag()
      //this mean you change the flag variable in this method
      //boolean flag = true;   
      flag = true;
   public boolean getFlag()
      return flag;
   public static void main(String[] args)
      Flag f = new Flag();
      System.out.println(f.getFlag());

Similar Messages

  • I can no longer edit the info for my songs, movies and tv shows.  This occurred since I loaded Windows 7 Pro on my C drive, and then fownloaded ITunes 10.  Why will the program not allow me to access the track info to edit it?

    I can no longer edit the info for my songs, movies and tv shows.  This occurred since I loaded Windows 7 Pro on my C drive, and then fownloaded ITunes 10.  Why will the program not allow me to access the track info to edit it?

    Ah yes school boy error there out of frustration and discontent..
    My issue is with music/apps/films etc not downloading from iTunes / App Store.
    They initially fail and message is displayed stating unable to download / purchase at this time, yet if I retry it says I've already purchased (?) or alternatively I go to the purchased section and there they are waiting with the cloud symbol..
    However some items get frozen in the download window and cannot be retried or deleted. Message appears stating to tap to retry, but even if you stole every bath and sink in the uk you'd still not have enough taps.
    I post here as the iTunes guys are useless in there 'help' and have only advised posting here or phoning apple, at my expense, to explain a problem that could be rectified by forwarding my original email to a techie. However the tech team apparently don't have an email address as they're from ye olde Middle Ages..!
    Anyways I digress.
    So I tried sync to pc, but instead of showing the file as ready to listen/use/view, the iCloud symbol shows and I'm back to square one as the item is unable to download..
    At frustration station waiting for a train from pain...
    All my software is up to date, and had all worked fine prior to the last big iOS update that resulted in all the changes in display and dismay.
    Answers in a postcard :-)
    Much love

  • Hello! I have a question why uninstalled the program MELOMAN? we are even ready to buy!

    hello! I have a question why uninstalled the program MELOMAN? we are even ready to buy!

    What are you talking about?

  • Why do the programs I installed quit unexpectedly?

    I installed AIM to my imac, but then I have to keep installing it onto my computer and when the program actually starts it just quits out of nowhere in 5 minutes.
    The same is also happening to my Parallels Desktop 3.0 when I want to run the program, I try opening the program up, once its installed, and my computer says that "Parallels Desktop quit unexpectedly."
    What do i do?!

    Hi.
    Why would you want AIM on the Mac? Did you know that the Apple application called iChat does just that? It's the Mac own chat application that communicates between .Mac and AIM members.
    So, if you do not have a .Mac account (you are seriously missing out) but an AIM account then log in to iChat with that.
    Also, always make sure that you update your software in regards of the Parallels program. However if you run in the trouble with third-party programs then you need to contact their tech support.
    Hope this helps^^

  • Why was the program automatally  shut off immediately  ?

    I  bought I pad in HK .  When I used QQ and memory note,  when I wrote "我” , the program was shut off immediately , I has to visit the program  again.  Why ?  

    I cannot speak to this specific instance, but many times, when the pad shuts down unexpectedly, there is simply a memory problem.   Double tap the home button and see the apps in the recently used area.  Most of them are simply recently used, but some do continue to keep some memory reserved.
    Double tap to see the task bar.  Touch and hold any of those icons until they jiggle, then shut them down by touching the minus sign.
    Them reboot.  Press and hold the sleep and hold buttons until you see the apple logo.  Ignore the red slider.
    Going through the task bar and closing off old apps is a good way to keep the machine running well.

  • Why is the program throwing an IO Exception?

    Hallo,
    I am trying to figure out how the URL and Socket class works, to write a small program, which is downloading stuff, from a given internet side.
    import TerminalIO.*;
    import java.net.*;
    import java.io.*;
    public class Downloader
         private String dlto;
         private String dlfrom;
         private int dlport=80;
         public boolean done=false;
         public static void main(String [] args)
              KeyboardReader in = new KeyboardReader();
              char again='n';
              do
                   System.out.println("Press enter if u want to save in the default folder");
                   String to = in.readLine("Where do u want to save?: ");
                   String from = in.readLine("From where do u want to download?: ");
                   Downloader dl = new Downloader(to, from);
                   System.out.println("It is "+dl.done+" that it is done");
                   again=in.readChar("Enter Y for yes if u want to run the program again,\nN if u don't:\n");
              }while(again == 'Y' || again == 'y');
         public Downloader(String where, String what)
              dlto=where;
              dlfrom=what;
              start();
         private void start()
              try
                   int len=0;
                   InetAddress addr = InetAddress.getByName(dlfrom);
                   //Displays from where the client is downloading
                     System.out.println("Downloading from: "+addr.getHostName());
                    System.out.println("At IP: "+addr.getHostAddress());
                   //tries to connect to witht the URL object, if it fails uses the Socket object
                   Socket sock=null;
                   URL url=null;
                   try
                        url = new URL(addr.getHostName());
                   catch(IOException e)
                        sock = new Socket(addr.getHostName(), dlport);
                   //getting the InputStream
                   InputStream in;
                   if(url ==null)
                        in=sock.getInputStream();
                   else
                        in = url.openStream();
                   //Saving the Downloaded Data
                   FileOutputStream out = new FileOutputStream(dlto);
                   System.out.println("Byte length, to download: "+in.available());
                   byte[] b = new byte[in.available()];
                   System.out.println("Downloading to: "+dlto);
                   while (in.read(b) != -1)
                        out.write(b, 0, in.read(b));
                   //closing the output
                   out.close();
                   in.close();
                   done=true;
              catch (MalformedURLException e)
                   System.out.println("Address not found");
              catch (IOException e)
                   System.err.println(e.toString());
                   System.out.println("-->IO Exception");
    }this is the Code i just wrote, but like i said in the subject, it is throwing an IOException in anycase. I could even try to download data from my own harddrive. So what shall i do? The thing which is confusing me the most, is that it actually displays the Name and the IP address, so that it seems to have access to the internet, but somehow it does not download the things, but i have no clue why. Please help.
    null

    I figured out how to get around the exception, but somehow, it still does not work correctly, the hole thing does not copy the hole thing, which is confusing me.
    <br>
    dint runs=0;
                        boolean terminate=false;
                        int len=0;
                        while ((len=in.read(b)) != -1 && terminate)
                             out.write(b, 0, len);
                             runs++;
                             if(runs ==2000 && in.read(b)==0)
                                  terminate=true;
                                  print+=("-----------------"+"\n");
                                  print+=("The file is empty"+"\n");
                                  print+=("-----------------"+"\n");
    Sorry, [ c o d e ] does not work anymore
    <br>
    <br>
    this somehow just copies an emtpy string, but how can i make it that it works, even with an element which length i don't now? by the way in.read(b) returns 3000 something with the test file i am using, but still the created file has a bit length of 0
    sorry, somehow all edditing commades do not work enymore.
    Message was edited by:
    betlor

  • Why is the program asking for a password to color a PDF. I changed the end to png and it was working and now quit

    I was using PDF from a nonprofit i work for to color with PS Elements. It worked and then no longer allows me to drop files into PS Elements.
    First I download the PDF's ....then I change the end from PDF TO .png and then drag and drop into PS Elements ....color .....
    Then I put the files into DropBox  and send them to iphoto to use in Doceri
    FIrst the error message was about Parse
    Now the message is that I need a password to use the program.
    Friends all over the country can get this to work but it is NOT WORKING. I emptied and redownloaded dropbox.....not the problem.
    We set up a dummy account and still could nto use.

    PSE asks for a password when the file was password protected by whoever created it. You can't really expect decent results if you just change the extension of a file. A PDF is a very different animal than a png file and contains very different information, so it's not surprising your results are poor. That's the sort of thing you may get away with once in a while, but you can't expect to use it as a regular workflow.
    Your whole procedure sounds extremely complicated for no particular good reason, at least as you describe it. It would be simpler to open the pdf in Preview and save a copy as a png if that's the format you need, but saving a pdf as anything other than a pdf will generally create a lousy looking file. I would just leave PSE out of the equation here, since you don't seem to be doing any editing with it.

  • Why does the program crash when I select Editor?

    Everytime I start up my Adobe Photoshop Elements 7 and select "Editor", the program stops and it crashes.  I never had this problem before and I'm getting absolutely nowhere with the webpage to find a solution.  Any help would be appreciated.

    I am having the same issue with 8 and am not getting a response either!  Don't you love Adobe's "support"?  Very frustrating!!  Let me know if you hear anything or have any luck and I will do the same.  Good luck!

  • Why does the program panel fail to match magnification of source panel?

    The magnification and resolution settings for both program & source panels are identical. However, the magnification on the program panel is much higher than the source. The rendered video, of course, is produced with the higher magnification thereby blocking out  a substantial % of the desired frame. What can I do to match the magnification of the source panel to the program panel? Thanks for your input in this regard!

    It sounds like your Sequence setting
    does not match your footage.
    Try this:
    Or, right-click a media file and select 'New Sequence From Clip".
    How do I choose the right sequence settings?
    http://www.video2brain.com/en/lessons/how-do-i-choose-the-right-sequence-settings

  • Why are the programs in my creative cloud not showing?

    Hi I've been trying to download programs out of my creative cloud and they're not showing up, I uninstalled and re-installed it back on my computer and I'm still having the same problem. I also upgraded from the single plan to the full plan where I can download everything and I can't download the programs either.
    Thanks

    Sign in, activation, or connection errors | CS5.5 and later
    Mylenium

  • Why does the program keep signing me out

    The program does not let me sign in. It will work for a second, freeze, then displays "You've been signed out". Please help as I would like to use this  program.

    Hi blum,
    please check this one You are no longer signed into your Creative Cloud applications
    regards

  • Finder: "Devices" vs. "Places."  Why are the programs different?

    I'm perpetually perplexed by the way the the same applications work differently under "Devices" and under "Places" when accessed from the "Finder." For example, often when I access a program like iPhoto from the Finder and click on it, it will appear to the extreme right on my dock, next to the stacks divider, thereby giving me 2 icons of iPhoto on my dock. Moreover, the one that appears on the far right may be of a different size and behave like a program being used for the first time. At other times, accessing the program from the Finder merely opens the one program on my Dock, as I expect it to. But must there be two appearances of the same icon, each appearing to be a discrete, separate application (as I suspect they are) rather than a mere alias of, or short cut to, the same program?
    A most recent example: I downloaded iTunes 10 (twice, for good measure). Nevertheless, I'm now looking at two different iTunes programs: iTunes 10 is under 2 of the rubrics in the "Devices" area of my Finder ("my iMac" and "Macintosh HD"); iTunes 9 remains lower down under 2 rubrics in the "Places" area (under "Applications" and under "my name" as sole user of the computer). They clearly must be separate, discrete applications, with different file sizes, though I would prefer to have only iTunes 10--and located under "A Applications" in the "Places" area of the Finder window.
    Normally, I would access applications under the "Applications" rubric that's found in "Places" on my Finder. Doing so, however, would seem to require that I trash my old iTunes (or iPhoto) and replace it by dragging down the newer version of iTunes recently installed in the "Devices" area of the Finder. Is this normal procedure? I plan to make less use of the Finder and concentrate on what's in the Dock. But when dragging an application to the Dock, is it important to select the application from the Devices area ("Macintosh HD") rather than the "Places" area ("Applications") to ensure placing the most recent version on the Dock? And is it normal to see two versions of the same application appear on the Dock after clicking on the program in the "Devices" area and the "Places" area of the Finder window?
    I'm analytically-challenged but am looking to reduce clutter without inadvertently trashing what may be substantial. I could also use any enlightenment concerning the complex and multiple locations (apparently 4) of a program/application as seen from the Finder window.

    I'm perpetually perplexed by the way the the same applications work differently under "Devices" and under "Places" when accessed from the "Finder." For example, often when I access a program like iPhoto from the Finder and click on it, it will appear to the extreme right on my dock, next to the stacks divider, thereby giving me 2 icons of iPhoto on my dock
    Sounds like you have 2 copies of iPhoto installed.
    On the dock icon, right click -> show in Finder and see where the applications are located then delete one of them
    Drag iTunes 9 to the trash to delete it.

  • I have 29 days left of the trial version of Creative Cloud. Why did the program stop functioning? No output whatsoever...

    Just downloaded the 30day trial version of creative cloud. I still have 29 days left. All of a sudden program stopped functioning. No output whatsoever. What happened?

    [email protected] wrote:
    and when I click on 'continue trial', I am unable to use the program, as far as record and/or playback.
    Okay, let's assume that it opens, and that the transport doesn't work. If this is the case, then there's only one thing that stops it - no valid sound device found. Go to the Preferences menu and look at your hardware, and select something relevant (probably an internal device). If the answer isn't obvious, report back on what you see there.

  • When deleting bookmarks from Firefox, why does the program respond differently on similar installs to different computers all running OS X?

    On the subject of bookmarks...
    The following procedure works for deleting bookmarks on my MacBook Pro, my iMac, and my Mac mini...
    If the bookmark is itself a tab on the toolbar, right click on it and select delete by highlighting delete in the drop down menu that appears.
    The following procedure works for deleting bookmarks on my MacBook Pro, but not my iMac or Mac mini...
    If the toolbar tab is actually a folder containing bookmarks and possibly more folders, left click on the toolbar tab to open a drop down menu of other bookmarks/folders, highlight the one you want to delete, then right click on it and select delete by highlighting delete in the drop down menu.
    On the iMac and Mac mini, right clicking on an item in the drop down menu of bookmarks/folders has no effect. It does not produce the additional drop down menu at all.
    I can find no place to adjust this as a setting in preferences or anywhere else. Can you tell me why I am seeing a different response from the Firefox program on my MacBook Pro than I get from my other Macs?
    All Macs are configured similarly and running OS X 10.6.5. All have Firefox 3.6.13 installed.
    I realize there are many other ways to delete bookmarks from Firefox. My question is not about how to delete bookmarks, but rather why am I seeing the differing behavior from Firefox in other installs. It may well prove to be an issue within OS X rather than Firefox.

    In case you are using "Clear history when Firefox closes" then try to disable this feature.
    *Tools > Options > Privacy > Firefox will: "Use custom settings for history": [ ] "Clear history when Firefox closes"
    *https://support.mozilla.org/kb/Clear+Recent+History
    Create a new profile as a test to check if your current profile is causing the problem.
    See "Creating a profile":
    *https://support.mozilla.org/kb/profile-manager-create-and-remove-firefox-profiles
    *http://kb.mozillazine.org/Standard_diagnostic_-_Firefox#Profile_issues
    If the new profile works then you can transfer files from a previously used profile to the new profile, but be cautious not to copy corrupted files to avoid carrying over the problem
    *http://kb.mozillazine.org/Transferring_data_to_a_new_profile_-_Firefox

  • Why is the camera such poor quality to take still pictures.

    I have been trying other a
    Apps to see if the quality of the still shots can get better.
    No such luck. It just looks like a grainy picture.
    Is there anything that can make this take good still pictures?
    Especially for the price you pay for one of these things?

    Yes I must admit the camera on the Iphone is very good.
    Yes the Ipad is well bait big to hold in the palm of your hand so to speak.
    But it would be nice to be able to take a quick snap if a picture becomes apparent.
    It would have been nice to have the Iphone camera in the Ipad2.
    Oh well just have to be disappointed about this feature.
    Question to any one. Is there an app that allows you to take a picture from a movie you made on the Ipad2 at all?
    As the camera picture is clear enough for me when I pause it.
    Thanks

Maybe you are looking for

  • Why doesn't work my wifi on my one year old phone?

    Dear Apple Support, I have a problem with my phone (Iphone 4S). I bought my phone in November 2012. The problem is that the wifi does not work on my phone since approximately December 2013. This very unfortunate for me, becouse the warrancy terminate

  • Rename a group of photos.

    Does anybody know a simple way to rename a batch of photos in 'Photos'? I want to rename 50+ photos with one name + sequential of numbers e.g. Garden 001.....Garden 053, but there doesn't seem to be a simple way. I used to do the change in Aperture,

  • Unable to import volumes in 10.3 webtool

    When trying to import volumes in the webtool in 10.3 I receive this error. This worked in 10.2. Error:      can't execute command - no drive specified for this session I know from using the command line that you should not have to choose a drive and

  • IPhone 5S scheduled for 9/24 then 10/7 has been shipped!

    >> Duplicate post removed to comply with Verizon Wireless Terms of Service.  See Re: iPhone 5S shipping postponed from 09/24 to 10/07 << Message was edited by: Verizon Moderator

  • Discoverer portlet - Location of images for page display

    Can anyone tell me where the portlet provider knows where to find the images that appear (like the expand button image on the list of worksheets portlet). If I look at the url in the page source , it is referencing http://<myserver>:7780/.... Is it h