New to OOP Java syntax

Hello there, I'm new here and I'd be thankful if you help me a bit with my self introduction to Java. I'll write down a source of main and hope you will tell me my beginner's problems:
import java.util.*;
//public int createdInstances = 0;
public class Students{
     private String name;
     private String course;
     public Enum Specialty{
          administrator, developer, designer, none
     public Specialty specialty;
     public Enum University{
          TU, SU, NBU, none
     public University university;
     private String email;
     private long phone;
     public static int instances;
     public Students(){
          this.name = "nullStudent";
          this.course = "nullCourse";
          specialty = Specialty.none;
          university = University.none;
          this.email = "none";
          this.phone = 0;
     public Students(String name, String course)     {
          this.name = name;
          this.course = course;
          specialty = Specialty.none;
          university = University.none;
          this.email = "none";
          this.phone = 0;
     public Students(String name, String course, String email, long phone){
          this.name = name;
          this.course = course;
          this.email = email;
          this.phone = phone;
     public void Viewer(){
          System.out.println("Name: " + name + " course: " + course + " @email: " + email + " #phone: " + phone);
public class Tasks{
     public static void main(String args[]){
          Students guys = new Students();
          guys.Viewer();
}Thanks in advance.

You can make a method that converts a string to a Server like this:
    enum Server {
        CPU, RAM, HDD
    public Server stringToServer( String s ) {
        if ( s == "CPU" ) {
            return Server.CPU;
        } else if ( s == "RAM" ) {
            return Server.RAM;
        } else if ( s == "HDD" ) {
            return Server.HDD;
        } else {
            throw new IllegalArgumentException(); // or any other error handler :)
    }

Similar Messages

  • New improvement for Java syntax

    Hi developers
    I develop in java each day and the new project that I am envolved uses too much multithreading. So i thought that a litle improvement could be made on java syntax.
    When two threads uses the same class attribute we must synchronize the access to this.
    class myClass {
    private int myAtribute = 0;
    thread1: We must access the attribute synchronized....
    shynchronized (this) {
    myAttribute = 1;
    thread2: The same....
    synchronized (this) {
    myAttribute = 3;
    thread2: But if i don't care.... :-(
    myAttribute = 4;
    Ok, that is the problem.
    I thought to solve this the java language must give us the chance to declare attributes in the way...
    private synchronize int myAttribute = 0;
    to be only accesed by sinchronized methods or by synchronized blocks in order to force interpreter to check if any method access this attribute without being synchronized in compiling time.

    In your example, wouldn't the volatile keyword normally suffice?
    private volatile int myAttribute = 0;Graeme

  • What is new in Java syntaxes in new Java versions?

    What is new in Java syntaxes in new Java versions?
    What about this sentenses
    1. for (int c:data), where data is array of integer
    2. ArrayList<Object> () ...
    3. Class<?>...
    I can't find this syntaxes in my books and documentation...
    And what Java version is latest?

    dont crosspost
    Edited by language police

  • Java "Syntax" should be a main button.

    So I really like the idea of the new syntax and such, but I think it's annoying that 1.  I have to go to "advanced" reply to use "Java" syntax, and just having to click and scroll to it can be annoying(even though it takes 10 seconds.as it
    ImO I loved being able to do {code}{code} as it was fast and easy, so something like that would be cool, or just having the little Java button on top.  Is tables really more important than Java Syntax on a Java forum?
    Thanks for the forum!

    For a radio button group called 'frequency' where the value binding is
    1 - weekly
    2 - bi-weekly
    3 - monthly
    4 - annual
    you could add the following client-side JavaScript to the 'frequency' change event.
    var frequency = form1.subform1.frequency.rawValue;
    switch (frequency) {
    case "1":
    form1.subform1.annual.rawValue = form1.subform1.pay.rawValue * 52;
    break;
    case "2":
    form1.subform1.annual.rawValue = form1.subform1.pay.rawValue * 26;
    break;
    case "3":
    form1.subform1.annual.rawValue = form1.subform1.pay.rawValue * 12;
    break;
    case "4":
    form1.subform1.annual.rawValue = form1.subform1.pay.rawValue * 1;
    break;
    default:
    break;
    Steve

  • Autofilled Java Syntax

    I use Adobe Adge Animate. I'm new in Adobe Edge and Java. I'm from the PHP side and use Dreamweaver. Its not possibly to autofilled Java Syntax in Edge? I have some problems with access of some symbols and element. I'm not sure which is the right command.

    When in the code window select the arrow at the bottom to open the code snippets.
    On Fri, Feb 13, 2015 at 4:55 PM, migro1982 <[email protected]>

  • When i download software, then go to the download window and click on the file, it is aking me to open it with a launch application. how do i figure out what app to use. ex; downloaded a new version of java, what app do i use to install?

    when i download software, then go to the download window and click on the program , i'am being ask to choose a launch program. how do i figure out what app to use to install. ex: i downloaded a new version of java and a game program. how do i install?

    Where did you download the java?
    Download it from here [https://www.java.com/en/download/index.jsp https://www.java.com/en/download/index.jsp]

  • New to Java Script(Want to open a new window using Java Script)

    Hi all,
    I am new to using Java Script. Now I have a HTML(First.html) page with a ADD button at the end of the page. What I want to know is, if I drag and select some part of the First.html and click on the ADD button a second HTML page(Second.html) should open displaying only the selected contents....
    Please help :-(

    myRef = window.open(self.location,'mywin',
    'left=20,top=20,width=500,height=500,toolbar=1,resizable=0');

  • Java Applets not working in New Versions of Java

    I have developed a chat program using Applets(developed using jdk1.2),using a Server.Everything is perfectly working.Now,On my client machine i installed jdk1.4, and when i try to download the same applet it is giving Applet ClassNotFound Exception?.
    I have just set the class path to jdk1.4.And trying to call the applet from a browser.
    IS there any changes in writing the applets using the new version of Java?
    Kindly let me know.
    Thanks & Regards.,
    Naveen Kumar

    Sorry can't use em anymore.
    ah, ... perhaps not.
    What class is not found?

  • New to XML+Java: which is the best API?

    Hi,
    I am new to XML+Java and I am trying to develop an application that will both read and write to an XML file. After reading some tutorials, I decided that jaxp, sax, and org.w3c.dom.* are rather low-level and very unfriendly.
    After a cursory web search, I came to the conclusion (please correct me if I am wrong) that JDOM and DOM4J are the most easy-to-use free APIs. So I would like to ask which one of the two (or any other API) is the "best"? With "best" I mean larger user base, better documentation, more features, less bugs, active development community (i.e. if a bug gets discovered, it will be fixed). I don't want to start building my application, just to realise 6 months later that the API I've chosen is very limited.
    Your experience is much appreciated. Thanks for taking the time to reply.

    Thanks guys. It seems that there is no clear answer as to which one should I use.
    I will start using dom4j because it has more convenience methods and it heavily uses JCF, which I am very comfortable with. Although it seems that the learning curve is steeper (more complicated API) it is probably worth the effort.
    Thanks again for your responses.

  • Hello Friends, I am new in InDesign Java Script

    Hello Friends,
    I am new in InDesign Java Script. I want to edit the page's master text Frame Object through Java Script. Any Idea regarding this will help me a lot.
    thanks in advance

    Have you read any of the documentation? It doesn't seem so :-)
    Vivek Singh, the documentation is a great tool for understanding object model. Once you got the main concept of hierarchy between objects, accessing objects is quite a child game.
    I am not meaning scripting is easy but have a look on the documentation, it's a essential starting point. I bought too the Peter Karhel's guide
    http://oreilly.com/catalog/9780596528171/index.html
    it's really cheap regarding to the quality of the learning.
    Welcome in this world.
    BTW, masterspreads is a property of document. So you should work with something like :
    app.activeDocument.masterSpreads[0].xxx
    Loic

  • [svn] 3127: Updating asdoc to replace the avmplus call with new set of java files.

    Revision: 3127
    Author: [email protected]
    Date: 2008-09-05 14:16:53 -0700 (Fri, 05 Sep 2008)
    Log Message:
    Updating asdoc to replace the avmplus call with new set of java files.
    Removing all files related to asdochelper.
    QA: Yes, also please test on non windows platform.
    Doc:
    Tests: checkintests, asdoc
    Reviewed by: Pete Farland
    Modified Paths:
    flex/sdk/trunk/asdoc/templates/ASDoc_Config_Base.xml
    flex/sdk/trunk/asdoc/templates/asdoc-util.xslt
    flex/sdk/trunk/modules/compiler/build.xml
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/asdoc/AsDocAPI.java
    Added Paths:
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/asdoc/AsClass.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/asdoc/AsDocHelper.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/asdoc/AsDocUtil.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/asdoc/QualifiedNameInfo.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/asdoc/SortComparator.java
    flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/asdoc/TopLevelClassesGenerator.ja va
    Removed Paths:
    flex/sdk/trunk/asdoc/templates/asDocHelper
    flex/sdk/trunk/asdoc/templates/asDocHelper.linux
    flex/sdk/trunk/modules/compiler/asdoc/

    I had a generic record class that has a HashMap to hold the data fields (...)
    method called createRecord() for each record type which would populate the HashMap with the correct data fieldsI'm not sure I understand: are the contents of this field map the same between two records of the same type? Then yes, you don't need to clone the map per record instance.
    one thing that needs fixing is the fact that each time the createRecord() method is called I'm creating a new fieldMap to define the dataFields in the record class.Probably, but that will only get you a little bigger files; you won't gain an order of magnitude on the size of files. The problem for huge files is that as soon as their content is bigger than the available memory, you'll run into problems. A more radical approach if you need to address huge files is to process the records on the fly, and not load all records in memory. Of course not all algorithms or business logic can afford that...
    I know I could rewrite the code and create a class for each record type and declare the fieldMap static but I was wondering if anyone had any better suggestions The Record instance could receive and keep a reference to its RecordType instance, and ask the RecordType instance the DataType for a field's name. That way the RecordType encapsulates the map, and there's less risk that a clumsy other class modifies the static map.
    before I go rewriting a load of code.A load of code?!? Even with the idea of the static map, you only have to edit the enum type (well more accurately, each RecordType enumerated constant's createRecord() method).

  • Can't install new versions of java under firefox,,i revert to explorer to do so

    when attempting to install the lastest version of java, firefox tries to load the install software instaed of providing me with run--->install buttons to click on. this has happened everytime a new version of java has become available,,my work around has been to bring up internet explorer and install java through it.

    You can save the Java installer to your desktop and start that file in the usual way with a double click.

  • Java syntax in vim

    can somebody help me set up correctly a java syntax in vim?
    what files should be changed? it seems like the default syntax is for c/c++.
    thx

    try ":help syntax"

  • New To OOPs ABAP

    Hi Friends, I am new to OOps ABAP,
    can any give me the differences between Procedural ABAP & OOps ABAP ?
    what is class ?
    what is Object ?
    thanks
    vijaya

    OOPS – OO ABAP
    http://esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt
    http://esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
    http://esnips.com/doc/0ef39d4b-586a-4637-abbb-e4f69d2d9307/SAP-CONTROLS-WORKSHOP.pdf
    http://esnips.com/doc/92be4457-1b6e-4061-92e5-8e4b3a6e3239/Object-Oriented-ABAP.ppt
    http://esnips.com/doc/448e8302-68b1-4046-9fef-8fa8808caee0/abap-objects-by-helen.pdf
    http://esnips.com/doc/39fdc647-1aed-4b40-a476-4d3042b6ec28/class_builder.ppt
    http://www.amazon.com/gp/explorer/0201750805/2/ref=pd_lpo_ase/102-9378020-8749710?ie=UTF8
    http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b5654f411d194a60000e8353423/content.htm
    http://help.sap.com/saphelp_nw2004s/helpdata/en/c3/225b5654f411d194a60000e8353423/content.htm
    DIRLL DOWN AND INTERACTIVE REPORT
    http://www.sap-img.com/abap/difference-between-drilldown-report-and-interactive-report.htm
    PAGE BREAK FOR ALV LIST
    check out this link
    http://www.abap4.it/download/ALV.pdf
    good book on ABAP objects(OOPS)
    http://www.esnips.com/doc/bc475662-82d6-4412-9083-28a7e7f1ce09/Abap-Objects---An-Introduction-To-Programming-Sap-Applications
    How to check Cluster Table Data
    https://forums.sdn.sap.com/click.jspa?searchID=5215473&messageID=3520315
    http://www.sap-img.com/abap/the-different-types-of-sap-tables.htm
    http://help.sap.com/saphelp_47x200/helpdata/en/81/415d363640933fe10000009b38f839/frameset.htm
    Check this cool weblog:
    /people/thomas.jung3/blog/2004/12/08/abap-persistent-classes-coding-without-sql
    /people/thomas.jung3/blog/2004/12/08/abap-persistent-classes-coding-without-sql
    http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b6254f411d194a60000e8353423/frameset.htm
    http://www.sapgenie.com/abap/OO/
    http://www.sapgenie.com/abap/OO/index.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/c3/225b5654f411d194a60000e8353423/content.htm
    http://www.esnips.com/doc/375fff1b-5a62-444d-8ec1-55508c308b17/prefinalppt.ppt
    http://www.esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
    http://www.esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt
    http://www.allsaplinks.com/
    http://www.sap-img.com/
    http://www.sapgenie.com/
    http://help.sap.com
    http://www.sapgenie.com/abap/OO/
    http://www.sapgenie.com/abap/OO/index.htm
    http://www.sapgenie.com/abap/controls/index.htm
    http://www.esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
    http://www.esnips.com/doc/0ef39d4b-586a-4637-abbb-e4f69d2d9307/SAP-CONTROLS-WORKSHOP.pdf
    http://www.sapgenie.com/abap/OO/index.htm
    http://help.sap.com/saphelp_erp2005/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm
    http://www.sapgenie.com/abap/OO/
    these links
    http://help.sap.com/saphelp_47x200/helpdata/en/ce/b518b6513611d194a50000e8353423/content.htm
    For funtion module to class
    http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b5954f411d194a60000e8353423/content.htm
    for classes
    http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b5c54f411d194a60000e8353423/content.htm
    for methods
    http://help.sap.com/saphelp_47x200/helpdata/en/08/d27c03b81011d194f60000e8353423/content.htm
    for inheritance
    http://help.sap.com/saphelp_47x200/helpdata/en/dd/4049c40f4611d3b9380000e8353423/content.htm
    for interfaces
    http://help.sap.com/saphelp_47x200/helpdata/en/c3/225b6254f411d194a60000e8353423/content.htm
    For Materials:
    1) http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCABA/BCABA.pdf -- Page no: 1291
    2) http://esnips.com/doc/5c65b0dd-eddf-4512-8e32-ecd26735f0f2/prefinalppt.ppt
    3) http://esnips.com/doc/2c76dc57-e74a-4539-a20e-29383317e804/OO-abap.pdf
    4) http://esnips.com/doc/0ef39d4b-586a-4637-abbb-e4f69d2d9307/SAP-CONTROLS-WORKSHOP.pdf
    5) http://esnips.com/doc/92be4457-1b6e-4061-92e5-8e4b3a6e3239/Object-Oriented-ABAP.ppt
    6) http://esnips.com/doc/448e8302-68b1-4046-9fef-8fa8808caee0/abap-objects-by-helen.pdf
    7) http://esnips.com/doc/39fdc647-1aed-4b40-a476-4d3042b6ec28/class_builder.ppt
    8) http://www.amazon.com/gp/explorer/0201750805/2/ref=pd_lpo_ase/102-9378020-8749710?ie=UTF8
    1) http://www.erpgenie.com/sap/abap/OO/index.htm
    2) http://help.sap.com/saphelp_nw04/helpdata/en/ce/b518b6513611d194a50000e8353423/frameset.htm
    Rewards if useful.................
    Minal

  • When loading firefox i get an error message, "can't find ////jpsnotify.exe. now firefox loads but every time i go into anything else it appears. this started to happen when i downloaded a new verison of java.

    i downloaded a new version of Java and i then started getting "windows can't find c:\java\jre6\lib\deploy\jqs\ff\..\..\..\bin\jqsnotify.exe. now this only happens when loading firefox. it happens through out the use of firefox when loading other programs. any suggestions?
    == This happened ==
    Every time Firefox opened

    Try re-installing Java. See [[Using the Java plugin with Firefox]]
    A quick search for jqsnotify.exe on Google indicates that it is related to the Java quick start option.

Maybe you are looking for

  • Formatting Text in Illustrator CS4

    Hello, I hope you can help me with this. When I am inserting text, sometimes when I insert a space it does not reflect in my text box. For Instance I say Bolt, 5/8 - 11 x 1 1/2 sometimes when I go to put a space after 5/8 it does not register in the

  • Kanban - External procurement with multiple vendor

    Hi Gurus, We are working on implementation of Kanban for external procurement (Scheduling agreement) in my organisation. As per the business requirement, some of the components are supplied by more than one vendor. As per the standard process, Kanban

  • Valuated and Non-valuated project stock in same SAP system

    Dear All,   Can we operate with the system where projects are with valuated and non-valuated project stock at the same time. If yes, are there any precautions we need to take before doing this.   Currently we are changing to 'valuated project stock'

  • I wrote a review, now I want to remove it..How?

    I wrote a review on itunes for a few things like albums and podcasts. Now I want to take a few of them off. How do I do it?   Mac OS X (10.4.7)  

  • ATG Privileges for Pages

    Hi, I am working with ATG User Authentications. So what i need to do is, restrict pages when UN-authorized person type URL and try to brows that page. I have created User Roles, Organizations and Users in BCC. I can access those users and roles using