Fundamental questions in Java, please help to answer.

I am a beginner of a Java Programming. Although I had few programming experiences on Java. But there are few conceptal questions. Hope every experts can help to explain more to me.
1. How <b>Encapsulation</b> works in Java? Why is it needed? What benefits can be given from encapsulation? Can give some examples for me to know more?
2. How <b>Overloading</b> works in Java? Why is it needed? What benefits can be given from it in the extensibility of programs? Can give some examples for me to know more?
3. How <b>inheritance</b> works in Java? What benefits can be given from inheritance? Can give further explanation, such as class hierarchy for me to know more?
4. What is <i>object class</i> and <i>object distances</i> ? What is their differences?
5. What is <b>Reusability</b>? What benefits can it gives? Why it is needed? Can give me further examples?
Thanks for help very much

Maybe I'm not getting this, but you want one of us to give you a nice short answer convenient enough for you to copy down, right? Well, there aren't many people here that are willing to do that. There are many people who won't even bother answering homework questions. I don't mind, but you need to show us some work you've done, like the previous poster said. The effort has to come from you, not us. If you are learning Java, you must put some effort into it.
How can you get an answer out of us?
Example: I understand that inheritance is ..............., but I'm not sure about this part.............. Can anyone provide some clarification please?
Anyway, this question has been crossposted on at least 5 forums already, which I'm sure is one of the reasons people aren't bothering with this question. Please DO NOT CROSSPOST, it's considered poor forum etiquette.
Please don't take anything that I said negatively, but you have to understand that we are taking our time to respond to your queries, and asking us to provide short answers without doing any work on your part, and crossposting is not going to get you answers out of us.
Cheers

Similar Messages

  • Main method question in java, please help

    Guys I have looked all over the internet, and cannot understand any of these questions: I would really appreciate any help on them. The first, and most important thing I would like to know is, what is static: what is a static int, or a static main method? Why is this necessary, and what does it do? Could you please provide an example? Also, why is String[] args necessary within the parameters of the main method? Is this so that it can execute it? Last thing is: objects. Where can I learn about them? I know they are made with the new operator, but don't understand their use? Could you explain why they are useful? Can you give them values? and how do they relate to the dot operator? After these are answered, I will be so happy because I will feel like I actually know a little bit. Right now, I'm just confused... Thank you so, so much in advance!

    The first, and most important thing I would like to know is, what is static'static' means that the item concerned is associated with the class itself rather than an instance: so, it is accessible to all instances.
    Could you please provide an example?
    public static void main(String[] args)is an example, but you knew that. I don't really understand the question.
    Also, why is String[] args necessary within the parameters of the main method?'args' receives the arguments you type on the command line after the class name or jar name, depending on how you invoke the application.
    This is all covered in the documentation, which you should read before asking further questions.
    Last thing is: objects. Where can I learn about them?If you don't know about objects you're not going to learn about them by asking questions on a forum. It's far too large a topic. Get yourself a book.

  • PLEASE HELP IN ANSWERING FEW QUESTIONS

    Hello Experts,
    i have few questions, could you please help me in getting familiar to this:
    1. What is Enterprise Structure?
    2. What is Organisational unit for for all SAP modules?
    3. can one chart of account can be assigned to more than one company code?
    4. how many company codes can be assigned to single company?
    5. All versions of SAP Till Now?
    Thanks!!

    Im pretty new to all this too, but this is how you validate an XML file against a XSD:
    You need to set the features of youre parser so that it is ready to validate.
    You will also need to extend the SAXErrorHandler with youre own CustomErrorHandler,
    parser.setFeature("http://apache.org/xml/features/validation/schema", validate);
    parser.setFeature("http://apache.org/xml/features/validation/schema-full-checking", validate);
    parser.setProperty("http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation", schemaUrl);
    CustomerErrorHandler handler = new CustomErrorHandler()
    parser.setErrorHandler(handler);
    parser.parse(xmlFiles);The XML file then needs t o have a reference to the XSD that is needs to be validated against at the top of the file:
    xsi:schemaLocation="http://www.w3schools.com c:\\WINNT\Desktop\youreXSD.xsd
    I think you will also need to catch and handle at least the SAXException....
    Hope this helps,

  • Pascal to Java Please help me!

    I am truobled in creating a validation method for the user loging in....
    As I am perfect at Pascal can anyone translate the following pascla code to Java Please help me with this.
    PROGRAM USERLOGIN;
    TYPE
      USER_TYPE = RECORD
        USERNAME : STRING[15];
        PASSWORD : STRING[15];
    END;
        USFILE = FILE OF USER_TYPE;
    VAR
       USER: USER_TYPE;
       CKUSER: USER_TYPE;
       RECFILE : USFILE;
       I,J     : INTEGER;
    BEGIN
    WRITE('ENTER USERNAME:');READLN(CKUSER.USERNAME);
    WRITE('ENTER PASSWORD:');READLN(CKUSER.PASSWORD);
    FILESPEC :='USERFILE.USR';
    ASSIGN(RECFILE, FILESPEC);
    RESET(RECFILE);
      WHILE NOT EOF(RECFILE) DO
       BEGIN
         READ(RECFILE, USER);
         IF CKUSER.USERNAME = USER.USERNAME AND CKUSER.PASSWORD = USER.PASSWORD THEN
              LOGIN
        ELSE
              WRITE('USER NOT FOUND');
       END;
    END.Thank you

    Don't bother:
    http://forum.java.sun.com/thread.jsp?forum=54&thread=539277

  • I forgot my security questions can you please help me?

    i forgot my security question can you please help me?

    See Here > Apple ID: Contacting Apple for help with Apple ID account security
              Ask to speak with the Account Security Team...
    Or Email Here  >  Apple  Support  iTunes Store  Contact
    More Info >  Apple ID: All about Apple ID security questions
    Note:
    You can only set up and/or change a Rescue Email BEFORE you forget the questions/answers.

  • No one has answer of my question?? please help!!

    hi gurus,
    i am trying to test sun provided demo programs for testing JAVA Mail API
    i am getting these errors please help me out ......
    thanks in advance
    DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
    DEBUG SMTP: useEhlo true, useAuth false
    DEBUG: SMTPTransport trying to connect to host "my.test-inc.com", port 25
    DEBUG SMTP RCVD: 220 X1 NT-ESMTP Server my.test-inc.com (IMail 6.05 30687-1)
    DEBUG: SMTPTransport connected to host "my.test-inc.com", port: 25
    DEBUG SMTP SENT: EHLO pankaj01
    DEBUG SMTP RCVD: 250-my.test-inc.com says hello
    DEBUG SMTP: use8bit false
    DEBUG SMTP SENT: MAIL FROM:<[email protected]>
    DEBUG SMTP RCVD: 250-SIZE 0
    DEBUG SMTP SENT: RCPT TO:<[email protected]>
    DEBUG SMTP RCVD: 250-8BITMIME
    Verified Addresses
    [email protected]
    DEBUG SMTP SENT: DATA
    DEBUG SMTP RCVD: 250-DSN
    DEBUG SMTP SENT: QUIT
    javax.mail.SendFailedException: Sending failed;
    nested exception is:
    javax.mail.MessagingException: 250-DSN
    java.lang.Throwable(java.lang.String)
    java.lang.Exception(java.lang.String)
    javax.mail.MessagingException(java.lang.String, java.lang.Exception)
    javax.mail.SendFailedException(java.lang.String, java.lang.Exception, javax.mail.Address [], javax.mail.Address [], javax.mail.Address [])
    void javax.mail.Transport.send0(javax.mail.Message, javax.mail.Address [])
    void javax.mail.Transport.send(javax.mail.Message)
    void adt.com.ocs.ldap.ui.SendFile.main(java.lang.String [])

    this is the output I'm getting through your program
    DEBUG: getProvider() returning javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsy stems, Inc]
    POP3: connecting to host "216.147.121.178", port 110
    S: +OK crescotec.com POP3 Server (Version 1.020h) ready.
    C: USER ritesh
    S: +OK please send PASS command
    C: PASS ritesh
    S: +OK 0 messages ready for ritesh in /home/cresco12/crescotec-mail/ritesh
    from: [email protected]
    to: [email protected]
    DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
    DEBUG SMTP: useEhlo true, useAuth false
    DEBUG: SMTPTransport trying to connect to host "216.147.121.178", port 25
    DEBUG SMTP RCVD: 220 yourserver.net ESMTP Sendmail 8.10.2/8.10.2; Wed, 25 Jul 2001 16:22:03 -0400
    DEBUG: SMTPTransport connected to host "216.147.121.178", port: 25
    DEBUG SMTP SENT: EHLO riteshnew
    DEBUG SMTP RCVD: 250-yourserver.net Hello 66-2-186-193.customer.algx.net [66.2.186.193], pleased to meet you
    250-ENHANCEDSTATUSCODES
    250-8BITMIME
    250-SIZE
    250-DSN
    250-ONEX
    250-ETRN
    250-XUSR
    250 HELP
    DEBUG SMTP Found extension "ENHANCEDSTATUSCODES", arg ""
    DEBUG SMTP Found extension "8BITMIME", arg ""
    DEBUG SMTP Found extension "SIZE", arg ""
    DEBUG SMTP Found extension "DSN", arg ""
    DEBUG SMTP Found extension "ONEX", arg ""
    DEBUG SMTP Found extension "ETRN", arg ""
    DEBUG SMTP Found extension "XUSR", arg ""
    DEBUG SMTP Found extension "HELP", arg ""
    DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
    DEBUG SMTP: useEhlo true, useAuth false
    DEBUG: SMTPTransport trying to connect to host "216.147.121.178", port 25
    DEBUG SMTP RCVD: 220 yourserver.net ESMTP Sendmail 8.10.2/8.10.2; Wed, 25 Jul 2001 16:22:03 -0400
    DEBUG: SMTPTransport connected to host "216.147.121.178", port: 25
    DEBUG SMTP SENT: EHLO riteshnew
    DEBUG SMTP RCVD: 250-yourserver.net Hello 66-2-186-193.customer.algx.net [66.2.186.193], pleased to meet you
    250-ENHANCEDSTATUSCODES
    250-8BITMIME
    250-SIZE
    250-DSN
    250-ONEX
    250-ETRN
    250-XUSR
    250 HELP
    DEBUG SMTP Found extension "ENHANCEDSTATUSCODES", arg ""
    DEBUG SMTP Found extension "8BITMIME", arg ""
    DEBUG SMTP Found extension "SIZE", arg ""
    DEBUG SMTP Found extension "DSN", arg ""
    DEBUG SMTP Found extension "ONEX", arg ""
    DEBUG SMTP Found extension "ETRN", arg ""
    DEBUG SMTP Found extension "XUSR", arg ""
    DEBUG SMTP Found extension "HELP", arg ""
    DEBUG SMTP: use8bit false
    DEBUG SMTP SENT: MAIL FROM:<[email protected]>
    DEBUG SMTP RCVD: 250 2.1.0 <[email protected]>... Sender ok
    DEBUG SMTP SENT: RCPT TO:<[email protected]>
    DEBUG SMTP RCVD: 250 2.1.5 <[email protected]>... Recipient ok
    Verified Addresses
    [email protected]
    DEBUG SMTP SENT: DATA
    DEBUG SMTP RCVD: 354 Enter mail, end with "." on a line by itself
    DEBUG SMTP SENT:
    DEBUG SMTP RCVD: 250 2.0.0 f6PKM4A18446 Message accepted for delivery
    DEBUG SMTP SENT: QUIT
    here is the code that I modified the I had just deleted my user name and password due to some confidentially problem at the organization. I think you can understand it here is the code the location where I had written
    xxxxxxx is the user name and ****** is a password.
    /**The Code*******************************/
    // Copyright (c) 2000 vitalspring
    package package1;
    * A Class class.
    * <P>
    * @author developer1
    import java.util.Properties;
    import javax.mail.*;
    import javax.mail.internet.*;
    public class Mailer
    public static void main (String args[]) throws Exception
    String smtpHost = "216.147.121.178";
    //String smtpHost = "smtp.mail.yahoo.com";
    String popHost = "216.147.121.178";
    // I had replaced my.test-inc.com to 216.147.121.178 the ip address that you can
    // get by typing the command ping and the server-name
    //String popHost = "pop.mail.yahoo.com";
    // String from = "[email protected]";
    // change this string to my username i.e the account that I have on the above hosts
    String from = "[email protected]" ;
    String to = "[email protected]";
    // String username = "pankaj";
    String username = "xxxxx" ;
    // String password = "pjha";
    String password = "*****" ;
    // Get system properties
    Properties props = System.getProperties();
    // Setup mail server
    props.put("mail.smtp.host", smtpHost);
    // props.put("mail.smtp.auth", "true");
    // Get session
    // I had just commented out this for testing
    // Session session = Session.getInstance(props, new MyAthenticator());
    Session session =Session.getInstance (props,null);
    session.setDebug(true);
    // Pop Authenticate yourself
    Store store = session.getStore("pop3");
    store.connect(popHost, username, password);
    // Define message
    MimeMessage message = new MimeMessage(session);
    InternetAddress addrTO=new InternetAddress(to);
    InternetAddress addrFROM=new InternetAddress(from);
    message.setFrom(addrFROM);
    System.out.println("from: "+addrFROM.getAddress());
    System.out.println("to: "+addrTO.getAddress());
    message.addRecipient(Message.RecipientType.TO,addrTO);
    message.setSubject("Hello JavaMail");
    message.setText("Welcome to Yahoo's JavaMail");
    Transport transport = session.getTransport("smtp");
    transport.connect(smtpHost, username, password);
    // Send message
    transport.send(message);
    class MyAthenticator extends Authenticator
    public PasswordAuthentication getPasswordAuthentication()
    return new PasswordAuthentication("pankaj","pjha");
    You must have received a mail from [email protected] at your account that you have specified here. I had also commented the authenticator method...
    Sorry your account at this server is not existing since its returned back to me . Anyway ...
    have a nice time

  • Why the same name of process comes out in AIX , in java. please help me.

    Hello.
    I have two questions related to Jvm.
    I've developed Job scheduler program which is doing somthing as the DB schedule is set in the way of Multi
    thread. Currently , I'm in the process of testing this one. It is good , if in the normal case. However, When
    doing Shell, if the application have so a lot to do the Shell, it has a little problem.
    My developing environment is
    OS : AIX 5.3
    JRE : IBM J9 VM (build 2.4, JRE 1.6.0 IBM J9 2.4 AIX ppc-32 jvmap3260sr7-20091214_49398
    (JIT enabled, AOT enabled)
    nofiles(descriptors) 2000
    maxuproc 4096 Maximum number of PROCESSES allowed
    per user True
    In order to execute Shell in My Scheduler program , I tested Runtimeexec() or ProcessBuilder.
    The result of mine in the test , when the executed Shell got over 300 is
         1. The jvm processes that I execute at the first time are shown up , after Shell go to the finish, the
    processes are all in the disappearance again , and at last The processes that I executed at the first time are
    remaining. It's like the process is duplicated process in the maximum of 70.
    When I do shell about 200 to be executed simultaneously, Duplicated jvm about 3 appeared momentarily, then
    disappeared, and also under 120, No duplicated case is found when under 120.
    ps -ef result is below , when shell is excuted
    UID PID PPID C STIME TTY TIME CMD
    jslee 626906 1 0 11, May - 2:20 java -
    DD2_JC_HOME=/source/jslee/JOB -Dfile.encoding=euc-kr jobserver.JobServerMain
    jslee 1421522 626906 0
    19:36:16 - 0:00 java -DD2_JC_HOME=/source/jslee/JOB -Dfile.encoding=euc-kr jobserver.JobServerMain
    ....Skip.....
    jslee 4374620 626906 0 19:34:06 - 0:00 java -DD2_JC_HOME=/source/jslee/JOB -
    Dfile.encoding=euc-kr jobserver.JobServerMain
    (the process list about 60)
    *the first question : Why a lot of duplicated jvm are shown up when in alot of shell to be executed ?
    *the second question : As you can see above , How can I solve out the problem.
    *Is there some option that I can set up when starting Jvm?
    ---Next question---
    My developing environment is
    OS : SunOS 5.8
    JRE : Java(TM) SE Runtime Environment (build 1.6.0_18-b07)
    Java HotSpot(TM) Server
    VM (build 16.0-b13, mixed mode)
    nofiles(descriptors) 256
    As shown obove , the value of descriptors is 256 .
         My scheduler program executed 300 shell at the same time, in result my program was abnormalily
    terminated after doing shell about 180.
    the Exception info is
    java.io.IOException: Cannot run program "sh": error=24, exceeding the number of opened files
         at
    java.lang.ProcessBuilder.start(Unknown Source)
         at java.lang.Runtime.exec(Unknown Source)
         at
    java.lang.Runtime.exec(Unknown Source)
         at java.lang.Runtime.exec(Unknown Source)
    or
    java.net.SocketException: exceeding the number of opened files     at java.net.PlainSocketImpl.socketAccept
    (Native Method)
    &#46608;&#45716;
    java.io.IOException: exceeding the number of opened files     at
    java.io.UnixFileSystem.createFileExclusively(Native Method)
         at java.io.File.checkAndCreate(Unknown
    Source)
         at java.io.File.createTempFile(Unknown Source)
    *question : If I continuously request to open a file that go over system limit, is it possible for JVM to be
    terminated?
    *question : Is there a method that obtains state of System limit in the java library.
    *question : what is the best solution to cope with ?
    Please help me
    =

    struts-config.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
    <struts-config>
      <form-beans>
           <form-bean name="registrationForm" type="ndlinh.struts.lab.RegistrationForm" />
      </form-beans>
      <action-mappings>
           <action path="/register"
                   type="ndlinh.struts.lab.RegistrationAction" // action class
                   name="registrationForm" // form bean name
                   validate="false"
                   scope="request"
                   input="registration.jsp" >
                <forward name="success" path="/jsp/success.jsp"  />
                <forward name="failure" path="/jsp/failure.jsp"  />
           </action>
      </action-mappings>
    </struts-config>HTH

  • IPhone 3g broken ,Genuis Bar Questions.  ****LONG**** PLEASE HELP

    Well i guess ill say the whole story. I bought my iPhone on August 6th and i had a plane to catch that day to Cali. So i synced it all up with my mac mini. My dad also got one and he went to Brazil (which is why im in Cali) While ive been here ive been syncing my iPhone with her windows computer to put apps on. Everything has been great until this week. Im calling it **** week. Ever since i updated to 2.0.2 its had no service most everywhere, apps and safari quit and when safari doesnt it runs extrememly slow and typing lag is worse then ever. I figured whatever maybe once i go back home it will start working again. Well thats not the case. Last night i was downloading apps and one of them got stuck when it was almost done installing. So synced it with my computer and it took it off.. well it still showed that it was installing. So i restarted my iPhone and it got stuck at the Apple logo(which is a common problem i know about the big thread also) so i restarted it and everytime it would go back to the Apple logo. I tried restoring it and everytime i plug it into my computer its makes my computer run extrememly slow and itunes wont come up. Then when i unplug it itunes pops up and everythings running normally. So after about 6 hours straight of trying to fix it, its now not turning on at all. Even when i plug it into a power outlet and computer. So basically i have a broken iPhone and its worthless. I have an appointment but im wondering if its even worth it.
    Genuis bar questions:
    1. Does the accoutn holder have to be present? Im on the account but not the account holder. My dad said to try.
    2. Will they try and hold my iphone? I cant leave it there because i have to leave that day.
    3. Would they just give me a new one? I would love that and not have to go through all this trouble
    Please help im stuck withotu a phone in the worst possible time.

    Jaden Hawk wrote:
    Genuis bar questions:
    1. Does the accoutn holder have to be present? Im on the account but not the account holder. My >dad said to try.
    No.
    2. Will they try and hold my iphone? I cant leave it there because i have to leave that day.
    No.
    3. Would they just give me a new one? I would love that and not have to go through all this trouble
    If there is a hardware problem with the iPhone they will replace it for you.
    You may want to update and restore the iPhone.
    http://docs.info.apple.com/article.html?artnum=305744
    Jason

  • I've got nothing(gray screen, question mark folder) Please Help!

    This problem is on my girlfriend’s computer, about the same as mine, PB G4 800mhz 768mb RAM, 10.4.x
    I am a competent user and this one has me worried…
    Problem
    Last night she goes to the computer sends an IM checks her e mail, watch some tv, goes back to the computer to look something up on line and its frozen, I do not recall if the mouse was visible but I don’t think there was a beach ball. She asks me what to do I said just give it a few minutes maybe it will process through what ever it is and be back to normal. We both forget to take a look at it before bed.
    This morning computer is still frozen/non-responsive and the fans are running... Shut down by holding down the power key. I try to re-start by pressing power key, screen lights up with gray background wait wait then the folder icon comes up with the question mark in it. This gets me worried.
    What I have tried
    I have tried to get it into target disc mode with my powerbook(computer B), I start up computer A holding down the T key and the screen goes to that moving firewire icon but the hard drive does not show up on my computer B.
    I tried unplugging it, removing the battery and re setting the pram
    I tried to run the hard ware test CD, but when I hold C to boot to the CD it spins up the disc and the little hardware test folder is in the middle of the screen but then it does not load any further. I had to shut down holding the power button. Computer would not eject CD so I had to start up and use unix eject cd command, this worked.
    I tried target disc mode again.
    I tried just a plain start up again.
    I do not have the 10.4 CD at my house so I have not tried to start from that yet, but I can borrow one from grandparents this evening after work, but I am worried since it will not start from the hardware test CD that it will not start from the system CD.
    I believe I have computer A backed up from either last week or the week before( I thought about doing it this weekend but did not get to it  ), she is not backed up daily as I am. Though she said there is quite a bit of important work from this past week.
    I have no idea what to do next or what the source of the problem could be(software or hardware). I fear the worst, but hope that you can share an idea that will turn out for the best!
    Please help me fix this computer, I can play with it some when I go home for lunch and then I need to get it fixed if possible this evening because she needs some important class work and grad school applications from it!
    Jerome

    So is the next step to try and re-format the drive and then use super duper to copy the back up over to that drive and then run disc utility and disc warrior on it? Which specs should I select for the re format, do they have to be the same as what is on my back up drive?
    Yes, reformatting the drive is the next step. Use your Panther installer discs, choose Mac OS Extended format, and check the box to install OS 9 drivers, just in case. The "Verified" SMART status is somewhat less reliable than a "Failing" status would have been: "Failing" definitely means trouble was detected, but "Verified" could just mean nothing seemed to be wrong right at the moment when you happened to ask. So if there's any trouble reformatting the drive, replace it: you shouldn't entrust anything important to it. If all goes smoothly with the reformat, the drive probably really is OK.
    What you can do with your backup depends on how you created it. If the backup is a bootable clone made with Carbon Copy Cloner or SuperDuper, you can clone it back to the reformatted drive the same way you created it in the first place, then add the extra files that were created or modified after you made the backup. If you just Finder-copied the drive to another drive, the backup isn't bootable, and copying it back onto the reformatted drive won't make that one bootable either: OS X isn't Finder-copyable. In that case, I really shouldn't advise you on reconstructing the former contents of the drive from your backup — my only experience of backing up OS X disks is by cloning, which eliminates all the hassles of making sure user accounts, passwords, permissions, etc. are transferred correctly to the backup, and then transferred correctly back to the original disk in a restore. Nearly four years after my adoption of OS X, I confess I'm still far more mystified by many aspects of it than I ever was by the old-time Mac OS.
    Message was edited by: eww

  • Very new to java please help

    i'm very new to java and i'm getting an error in my application. i took 4 applications that compiled and worked separatly and i tried to combine them into one application. i'm getting the error: unreported exception java.io.IOException; must be caught or declared to be thrown, in lines 73,78,83,88,120,146,149,152,155 in the and it points at the keyboard.readLine() but everything i've tried just gives me more errors. please help anything and everything will be greatly appreciated. here it is, sorry about format i dunno how to straighten it in here:
    // ^ ^
    //               (0)(0) A Happy Piggy Application
    // Problems: 2.6,2.8,2.9,2.12 (oo)
    // An application finds the total number of hours, minutes, & seconds, finds the distance
    // between two points, finds the volume and surface area of a sphere, and adds up the change
    // in a jar. First, the total hours, minutes, and seconds problem.
    import java.io.*;
    import java.text.DecimalFormat;
    import java.text.NumberFormat;
    public class twoptsix
         static BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in));
         static PrintWriter screen = new PrintWriter(System.out, true);
         public static void main (String[] args) throws IOException
              double hoursa, minutesa, secondsa;
              String hours;
              System.out.print ("Please enter a number of hours: ");
    hours = keyboard.readLine();
    hoursa = Double.parseDouble(hours); //asks programmer friendly user to enter hours
    String minutes;
    System.out.print ("Please enter a number of minutes: ");
    minutes=keyboard.readLine();
    minutesa = Double.parseDouble(minutes); //asks programmer friendly user to enter minutes
    String seconds;
    System.out.print ("Pretty please enter a number of seconds: ");
    seconds = keyboard.readLine();
    secondsa = Double.parseDouble(seconds); //asks programmer friendly user to enter seconds
    double allseconds;
    allseconds = (hoursa * 3600) + (minutesa * 60) + secondsa; //adds up all the seconds of the time entered
    System.out.println ("You have: " + hours + " hours..."); //displays hours
    System.out.println ("" + minutes + " minutes..."); //displays minutes
    System.out.println ("and " + seconds + " seconds..."); //displays seconds
              System.out.println ("to get whatever you need to done!"); //witty attempt at humor
    System.out.println ("The total amount of seconds is: " + allseconds + " seconds."); //displays total seconds
    // An application that finds the distance between two points when the points
    // are given by the user.
              double x1, x2, y1, y2, total, distance;
              String xa;
              System.out.print ("Please enter the 'x' coordinate of first point: ");
              xa = keyboard.readLine();
              x1 = Double.parseDouble(xa); //asks programmer friendly user to enter first x value
              String ya;
              System.out.print ("...also need the 'y' coordinate of first point: ");
              ya = keyboard.readLine();
              y1= Double.parseDouble(ya); //asks programmer friendly user to enter first y value
              String xb;
              System.out.print ("...and the 'x' coordinate of the second point: ");
              xb = keyboard.readLine();
              x2 = Double.parseDouble(xb); //asks programmer friendly user to enter second x value
              String yb;
              System.out.print ("...don't forget the 'y' coordinate of the second point: ");
              yb = keyboard.readLine();
              y2 = Double.parseDouble(yb); //asks programmer friendly user to enter second y value
              total = Math.pow(x2 - x1, 2.0) + Math.pow(y2 - y1, 2.0); //squares the differences of values
              distance = Math.sqrt(total); //finds the square root of the sum of the differences of the values
              System.out.print ("E=mc^2...oh and,");
              System.out.print ("the distance between point (" + xa +"," + ya +") and point("+
              xb + "," + yb + ") is : " + distance);
    // An application that takes the radius of a sphere and finds and prints
    // the spheres volume and surface area.
              double radius,volume,area;
              String rad;
              System.out.print("Please enter the radius of a sphere: ");
              rad = keyboard.readLine();
              radius = Double.parseDouble(rad); //asks programmer friendly user to enter the radius of a sphere
    DecimalFormat fmt = new DecimalFormat ("0.####");
              volume = ((4 * Math.PI * Math.pow(radius,3.0)) / 3) ;
              System.out.println (" The sphere has a volume of:" + fmt.format(volume)); //finds and displays volume
              area = ( 4 * Math.PI * Math.pow(radius, 2.0)) ;
              System.out.print (" The Surface Area of the sphere is: " + fmt.format(area)); //finds and displays surface area
    // An application that finds the total, in dollars and cents, of a number of quarters,
    // nickels, dimes, and pennies in your piggy bank.
              int pennies, nickels, dimes, quarters;
              double money1;
              screen.println("Empty your piggy bank and count the change, how many quarters ya have?: ");
              int q = (new Integer(keyboard.readLine())).intValue();//asks programmer friendly user to enter a number of quarters
              screen.println("How many dimes?: ");
              int d = (new Integer(keyboard.readLine())).intValue();//asks programmer friendly user to enter a number of dimes
              screen.println("How many nickels?: ");
              int n = (new Integer(keyboard.readLine())).intValue();//asks programmer friendly user to enter a number of nickels
              screen.println("How many pennies?: ");
              int p = (new Integer(keyboard.readLine())).intValue();//asks programmer friendly user to enter a number of pennies
              NumberFormat money = NumberFormat.getCurrencyInstance();
              money1 = (.25 * q) + (.1 * d) + (.05 * n) + (.01 * p);
              screen.println("You're rich! Total, you've got: " + money.format(money1));//finds and displays total money

    Ok here is the working code as one long function:
    // ^ ^
    // (0)(0) A Happy Piggy Application
    // Problems: 2.6,2.8,2.9,2.12 (oo)
    // An application finds the total number of hours, minutes, & seconds, finds the distance
    // between two points, finds the volume and surface area of a sphere, and adds up the change
    // in a jar. First, the total hours, minutes, and seconds problem.
    import java.io.*;
    import java.text.DecimalFormat;
    import java.text.NumberFormat;
    public class twoptsix
        static BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in));
        static PrintWriter screen = new PrintWriter(System.out, true);
        public static void main (String[] args) throws IOException
    double hoursa, minutesa, secondsa;
    String hours;
    System.out.print ("Please enter a number of hours: ");
    hours = keyboard.readLine();
    hoursa = Double.parseDouble(hours); //asks programmer friendly user to enter hours
    String minutes;
    System.out.print ("Please enter a number of minutes: ");
    minutes=keyboard.readLine();
    minutesa = Double.parseDouble(minutes); //asks programmer friendly user to enter minutes
    String seconds;
    System.out.print ("Pretty please enter a number of seconds: ");
    seconds = keyboard.readLine();
    secondsa = Double.parseDouble(seconds); //asks programmer friendly user to enter seconds
    double allseconds;
    allseconds = (hoursa * 3600) + (minutesa * 60) + secondsa; //adds up all the seconds of the time entered
    System.out.println ("You have: " + hours + " hours..."); //displays hours
    System.out.println ("" + minutes + " minutes..."); //displays minutes
    System.out.println ("and " + seconds + " seconds..."); //displays seconds
    System.out.println ("to get whatever you need to done!"); //witty attempt at humor
    System.out.println ("The total amount of seconds is: " + allseconds + " seconds."); //displays total seconds
    // }  <----- MAIN FUNCTION USED TO END HERE!!!
    //but we want to keep going so remove the bracket!
    // An application that finds the distance between two points when the points
    // are given by the user.
    // {  <-- other function used to start here, but now it continues
    double x1, x2, y1, y2, total, distance;
    String xa;
    System.out.print ("Please enter the 'x' coordinate of first point: ");
    xa = keyboard.readLine();
    x1 = Double.parseDouble(xa); //asks programmer friendly user to enter first x value
    String ya;
    System.out.print ("...also need the 'y' coordinate of first point: ");
    ya = keyboard.readLine();
    y1= Double.parseDouble(ya); //asks programmer friendly user to enter first y value
    String xb;
    System.out.print ("...and the 'x' coordinate of the second point: ");
    xb = keyboard.readLine();
    x2 = Double.parseDouble(xb); //asks programmer friendly user to enter second x value
    String yb;
    System.out.print ("...don't forget the 'y' coordinate of the second point: ");
    yb = keyboard.readLine();
    y2 = Double.parseDouble(yb); //asks programmer friendly user to enter second y value
    total = Math.pow(x2 - x1, 2.0) + Math.pow(y2 - y1, 2.0); //squares the differences of values
    distance = Math.sqrt(total); //finds the square root of the sum of the differences of the values
    System.out.print ("E=mc^2...oh and,");
    System.out.print ("the distance between point (" + xa +"," + ya +") and point("+
         xb + "," + yb + ") is : " + distance);
    //second function used to end here...
    //} <--- COMMENT OUT BRACKET SO WE CONTINUE
    // An application that takes the radius of a sphere and finds and prints
    // the spheres volume and surface area.
    //{ <--- ANOTHER ONE TO COMMENT OUT
    double radius,volume,area;
    String rad;
    System.out.print("Please enter the radius of a sphere: ");
    rad = keyboard.readLine();
    radius = Double.parseDouble(rad); //asks programmer friendly user to enter the radius of a sphere
    DecimalFormat fmt = new DecimalFormat ("0.####");
    volume = ((4 * Math.PI * Math.pow(radius,3.0)) / 3) ;
    System.out.println (" The sphere has a volume of:" + fmt.format(volume)); //finds and displays volume
    area = ( 4 * Math.PI * Math.pow(radius, 2.0)) ;
    System.out.print (" The Surface Area of the sphere is: " + fmt.format(area)); //finds and displays surface area
    // } <----- COMMENTED OUT FOR THE SAME REASON
    // An application that finds the total, in dollars and cents, of a number of quarters,
    // nickels, dimes, and pennies in your piggy bank.
    //{ <----AND ANOTHER
    int pennies, nickels, dimes, quarters;
    double money1;
    screen.println("Empty your piggy bank and count the change, how many quarters ya have?: ");
    int q = (new Integer(keyboard.readLine())).intValue();//asks programmer friendly user to enter a number of quarters
    screen.println("How many dimes?: ");
    int d = (new Integer(keyboard.readLine())).intValue();//asks programmer friendly user to enter a number of dimes
    screen.println("How many nickels?: ");
    int n = (new Integer(keyboard.readLine())).intValue();//asks programmer friendly user to enter a number of nickels
    screen.println("How many pennies?: ");
    int p = (new Integer(keyboard.readLine())).intValue();//asks programmer friendly user to enter a number of pennies
    NumberFormat money = NumberFormat.getCurrencyInstance();
    money1 = (.25 * q) + (.1 * d) + (.05 * n) + (.01 * p);
    screen.println("You're rich! Total, you've got: " + money.format(money1));//finds and displays total money
    }P.S. To make the code formatted better put [ code ] before and [ /code ] after. It's not perfect, but a little better...

  • Myfaces t:columns question...please help me...

    Hi guys,
    i've tried lots of solutions,but i think i've find right solution to solve my question.
    I have to create a datatable with a fixed number of columns and other dynamic columns.
    I've rendered it using t:columns of Myfaces and it works fine.
    It's a piece of jsp page
              <t:dataTable
        value="#{biosamplesTable.biosamples}"
        var="biosampleItem"
         binding="#{biosamplesTable.biosampleDataTable}"  >
        <h:column >
            <f:facet name="header">
                <h:outputText value="Organism" />
            </f:facet>
           <h:selectOneMenu value="#{biosampleItem.organism}">
                <f:selectItems value="#{getDropList.selectOrganism}"/>
           </h:selectOneMenu>
    etc..etc..   
            <t:columns value="#{biosamplesTable.columns}" var="col">
             <f:facet name="header">
                      <h:outputText value="Nuova" />
            </f:facet>
            <h:inputText value="#{biosampleItem.column}" />
        </t:columns>
         <h:column>
            <f:facet name="header">
                <h:outputText value="Actions" />
            </f:facet>
            <h:commandButton
            value="Invia dati biosample" actionListener="#{biosamplesTable.editBiosample}" id="editBiosample">
            </h:commandButton>
        </h:column>
    </t:dataTable>     
    </h:form>     
    }     My only question is:
    I'm able to retrieve the h:column values for each row,i do it in editBiosample method
    public void editBiosample(ActionEvent event) throws SQLException {
              setBiosampleItem((Biosample) getBiosampleDataTable().getRowData());
              try {
                   if (conn != null) {
                        Experiment exp = (Experiment) ViewUtils.eval("#{experiment}");
                        PreparedStatement pst3 = null;
                        pst3 = conn
                                  .prepareStatement("INSERT INTO  campione(id_,organismo,protocollotrattamento,metodoestrazione,tipoamplificazione,protocolloibridazione,protocollomarcatura)      VALUES(?,?,?,?,?,?,?)");
                        pst3.setInt(1, exp.getAutoKey());
                        pst3.setString(2, getBiosampleItem().getOrganism());
                        pst3.setString(3, getBiosampleItem().getTreatmentProtocol());
                        etc...
              pst3.executeUpdate();
              pst3.close();
              catch (Exception e) {
                   e.printStackTrace();
         }now i have to retrieve the h:columns values for each row,how can i do it?
    Please help me,i've started so but there is some error,each values is null!!
    For generating columns i've used..
    public List getColumns() throws Exception {
         if (load2 == 0) {
         for (int i = 0; i < 3; i++) {
              UIOutput input = new UIInput();
            ValueBinding myItem =
                FacesContext
                    .getCurrentInstance()
                        .getApplication()
                            .createValueBinding("#{biosampleItem[" + i + "]}");
            input.setValueBinding("value", myItem);
            UIColumn column = new UIColumn();
            column.getChildren().add(input);
              columns.add(column);
              load2=1;
         else this.columns=columns;
         // Reload after every request.
         return columns;
    }what's wrong?
    Please help me,i need to solve my problem...
    thanks in advance...
    Message was edited by:
    giubat
    Message was edited by:
    giubat

    Ok, you have more than one frame and when you make your dialog, it is only modal on one frame.
    Not sure how to make a workaround for that. That would proably require that when another frame got the focus, it should check if any of the frames has a modal dialog visible, and if that is the case, it should move the dialog to the front (dialog.toFront()).

  • M new to this forum + new to java please help me with file handling program

    hi i want to make a file handling program where in i want to input a text file say f1 whose style is mentioned as below
    aaa...bcd
    aaabbc
    acdce
    a..dd
    abbcd
    now i want to write d out put of file f1 to file f2 but only those string entries widout any ... in them how to do that :-(( please help :((

    import java.io.*;
    import java.lang.*;
    class javcsse{
             void javsce (){
              BufferedReader in;
            PrintWriter out;
            String line;
            try
                in = new BufferedReader(new FileReader("e:\\cntcs\\n7.txt"));
                out = new PrintWriter("e:\\cntcs\\n8.txt");
               line = in.readLine();
               while(line != null)
                     if(line.contains("...") && line.contains("....")){
                         break ;                
                         else{
                               if(line.contains("cc"))
                              System.out.println(line+"\n");
                                      out.println(line);
                    line = in.readLine();
                in.close();
                out.close();
            } catch (Exception ex)
                System.err.println(ex.getMessage());
      public class javcse{
        public static void main(String[] args) {
            new javcsse();
    }hey i wrote this code yet could u tell y is it still not working :((

  • I am new to java please help!!

    please help ive got a method thta i wanto to use it in another class, but it does not work.
    //prueba.java
    import java.io.*;
    public class prueba
    public int numero3;
    public int suma(int numero1,int numero2)
    int numero3=numero1+numero2;
    return numero3;
    //prueba1.java
    import javax.servlet.*;
    import java.io.*;
    import javax.servlet.http.*;
    import prueba;
    public class prueba1 extends HttpServlet
    public void doGet(HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException
    PrintWriter out = res.getWriter();
    int num1=1;
    int num2=1;
    prueba uno=new prueba();
    out.println(uno.suma(2,3));
    when i ty to complie this file it throws me thie errors:
    C:\resin-2.0.b2\doc\content-manager\admin\web-inf\classes\prueba1.java:4: cannot resolve symbol
    symbol: class prueba
    import prueba;
    ^
    C:\resin-2.0.b2\doc\content-manager\admin\web-inf\classes\prueba1.java:15: cannot resolve symbol
    symbol : class prueba
    location: class prueba1
    prueba uno=new prueba();
    ^
    C:\resin-2.0.b2\doc\content-manager\admin\web-inf\classes\prueba1.java:15: cannot resolve symbol
    symbol : class prueba
    location: class prueba1
    prueba uno=new prueba();
    ^
    3 errors
    Tool completed with exit code 1
    both , prueba1.java and prueba.java are in the same folder.

    C:\resin-2.0.b2\doc\content-manager\admin\web-inf\classes\prueba1.java:15: cannot resolve symbol
    symbol : class prueba
    location: class prueba1
         prueba uno=new prueba();
    ^
    C:\resin-2.0.b2\doc\content-manager\admin\web-inf\classes\prueba1.java:15: cannot resolve symbol
    symbol : class prueba
    location: class prueba1
         prueba uno=new prueba();
    ^
    2 errors

  • A few newbie questions...Please help!

    I'm brand new here - considering getting a Droid Incredible.
    Please help me with the following (albeit somewhat random!) questions...
    When I set up the phone, I only want to use Gmail. Will Gmail automatically be made my default email program, or will the regular HTC Mail program also be loading my Gmail? I'd rather not have conflicting notifications.
    Voicemail. Thinking of getting regular Basic Voicemail. Do I get notifications every time I get a voicemail? When I click on it, will it take me directly to the voicemail, or will I still have to jump through the password junk? Does Voicemail integrate with the regular Phone app, or is it different?
    Does Verizon give me my "Voicemail Pin" or whatever? Do they set it up at the store?
    Browser. Is there any way I can set it so that it goes to my home page every time  I open it? I hate when it continues from last time.
    THANKS IN ADVANCE! I know that I might sound stupid - but this is my first smartphone. I want it to be efficant, easy to use, and slick. Based on the reviews, the Incredible is all that.

    nytraveller53 wrote:
    THANKS EVERYONE ALREADY! You've already helped me a lot. I think I'm going to take a trip to the Verizon Store today, and discuss some details with them as well.
    A couple other questions I had, but I forgot to ask:
    Task Killers. I know many Android fans swear by them, but most of the "Tech Experts" (PC World, Wired, etc.) claim that Android is designed to do it by itself. Is a Task Killer really necessary? I personally do not use task killers as they are glorifed battery killers.
    How would I go about switching between open apps (WITHOUT using a third-party app), that is different from just going to the home screen again?
    SO...Pressing down "1" to get to voicemail needs to be programmed in at Verizon, correct? Making it so that I don't have to enter the password needs to be done at Verizon, correct? And Verizon will give me my voicemail PIN and Password, correct? Call *86 to get to VM. Once there, you will set up your VM and assign a pin. Just follow the instructions.
    The Droid Incredible was released almost a year ago now. Does it even make sense to sign up for a smartphone already that old, when I have to have it for 2 years? I'm thinking it might be better to wait for the new Thunderbolt. Your opinion? That is strictly a personal preference. If you are not near an area where LTE service will not be for a while, maybe the cheaper Incredible will be fine for you.
    Hulu. Am I correct that Hulu does NOT work on Android, even with Flash? Hulu has blocked access from phones except MAYBE iPhone, but I am not sure
    Can someone please give me a list of ALL the apps that CAME with the phone when you got it? (You know, calendar, mail, etc.) Too many to list. What you see is more than waht we got originally. More were added when Froyo came out.
    Do I NEED Adobe Reader to see pdf email attachments, or will the "Office" thing display all documents just fine? What does that built in app support anyway? Download the reader
    What "Verizon" apps comes with the phone? I don't want VCast and all that, just an app to monitor my minutes. I really hope Verizon doesn't load crapware (cough, HP, cough) onto the phone, do they? Vcast 'Comes' on the phone. You will see it and other apps you may never use on the 'Running' list, but do not dwell on it. If you want an explanation as to why they are 'Running', do a search. Simply they do not use resources unless you ARE using them.
    On the phone, are there both "HTC Sense" versions of apps AND regular stock Android apps, or is it all combined? I don't want two contacts apps, for example. You will end up with dup apps if you DL another app. But you can hide the one you do not want to use, if it came with the phone.
    Visual Voicemail. I'm considering it, it's just $2.99. And I'm NOT messing with Google Voice. Is VVM integrated with the regular dialer, or is it a seperate program? I've heard reports from both sides on this topic.
    How can I make it so the Browser starts up at the home page every time (NO Task killer, please!) You mean have a favorite web page open when you open the browser???
    How do you change the address in the web browser without navigating to "Menu" - "Go to" (that's a real pain). Is there a shortcut? Thanks! Bookmarks are your friend
     I plan on using this phone for maybe an hour in the morning, not very much during the day, and then about two or three hours total in the afternoon. Will the battery last without me having to turn off different features? I actually WANT the 3G, sync, etc. running! battery life depends on many factors.... Do a search of 'Battery Life' to have help with that
    I have super high speed Wifi in my home. When I set up wifi on the device initially, will the phone automatically connect to Wifi instead of 3G everytime I go home? Or do I do this manually? If you keep the WiFi switch on, yes. But keeping it on away from home KILLS the battery as the phone searches and searches
    Thanks again - I know these are very nitpicky and detailed questions, but I'm so close to getting the Incredible...I want the full scoop!!
    Thanks! I'll probably have more questions, thanks for helping me out! Forgive my stupid questions!

  • I forgot one of my questions can you please help me

    Can you please help me i forgot my dream job question please help me i really need this song please

    If you have a rescue email address (which is not the same thing as an alternate email address) set up on your account then the steps half-way down this page should let you reset them : http://support.apple.com/kb/HT5312
    If you don't have a rescue email address (you won't be able to add one until you can answer 2 of your questions) then you will need to contact iTunes Support / Apple to get the questions reset.
    Contacting Apple about account security : http://support.apple.com/kb/HT5699
    When they've been reset (and if you don't already have a rescue email address) you can then use the steps half-way down the HT5312 link above to add a rescue email address for potential future use

Maybe you are looking for