1. Welcome to the Brawl website! Feel free to look around our forums. Join our growing community by typing /register in-game!

Technology Lets talk Coding

Discussion in 'Off Topic' started by EmperorTrump45, Sep 28, 2015.

Thread Status:
Not open for further replies.
Please be aware that this thread is more than 30 days old. Do not post unless the topic can still be discussed. Read more...
  1. EmperorTrump45

    EmperorTrump45 Dank Memer

    Joined:
    Jul 3, 2015
    Messages:
    2,796
    Ratings:
    +2,157
    Hello!
    I am a programming newb and I had a few questions for the coders/anyone who knows more than I do about several things in Java, which I would look up if I was on a faster connection. Plus, I have a quiz in a few days and typing some code helps me prepare a bit better ^_^

    - What exactly is concatenation? As I understand it, it's something like this:

    public class WriteName {

    public static void main (String[] args) {

    System.out.println ("Hello /n" +
    "my name is"+
    "Ian");
    }
    }

    - What does polymorphism do?

    - What does encapsulation mean?

    - I'm not entirely clear on what identifiers are. Are those statements like: boolean, string, int, double, final, etc.?

    @NomNuggetNom
    @Mario
     
  2. Paul

    Paul Well-Known Member

    Joined:
    Aug 21, 2013
    Messages:
    1,987
    Ratings:
    +904
    concatenation:

    Combining 2 Strings to form 1
    Eg:

    String firstName = "Paul"
    String lastName = "G"

    String fullName = firstName + lastName

    polymorphism:

    If you're just getting into programming you shouldn't need to worry about this yet but I'll explain it anyways.

    If you have a super class "A" and a class that extends "A" called "B".

    This means "B" contains all the features from "A". To demonstrate polymorphism you could essentially add in a field to "B" which makes it unique from "A". (As an example)

    Code:
    public class A {
    
    String name = "poly"
    
    }
    
    public class B extends A {
    
    String b = "poly2" //polymorphism
    
    }
    
    encapsulation:

    simple def: getters and setters for private fields in your class. Used ALOT in OOP. USE IT

    Code:
    private String name;
    
    public String getName() { 
    return name; 
    }
    
    public void setString(String name) { this.name = name;
    }
    
    Yes, identifiers are:
    public, private, protected
     
  3. Signatured

    Signatured War 2.0 Developer

    Joined:
    Sep 13, 2013
    Messages:
    3,819
    Ratings:
    +1,402
    Concatenation is when you form a string using the '+'. This could be the combination of two strings, a string and an integer, or basically a string and anything else.

    Polymorphism basically means that sub classes can have their own unique behaviors, yet still share the same functionality as their parent class. You'll need to do more research on that one considering it's a little more advanced, to advanced to explain in one definition.

    Encapsulation is when take multiple data members (pieces of info about your object) and wrap it into one class. Think of it like your putting stuff in a protective container. Again, research this topic more for a better understanding.

    What you listed are called primitive data types. Access modifiers control how a method or variable is accessed from a different class, for example public/private.
     
  4. supercraft002

    supercraft002 Well-Known Member

    Joined:
    Oct 24, 2014
    Messages:
    225
    Ratings:
    +64
    concatenation is adding multiple strings together with a + e.g.
    Code:
    public string s = "aaaaaaaaa" + "bbbbbbbbb";
    encapsulation are basically access levels to fields , methods etc. e.g.
    Code:
    public class{
    //can not be accessed through an instance of the class
    private int x;
    //can not be accessed through an instance of the class
    public int y;
    
    public void doStuff(){
    
    
    }
    
    }
    getters and setters are so ugly in java x-x
     
  5. Signatured

    Signatured War 2.0 Developer

    Joined:
    Sep 13, 2013
    Messages:
    3,819
    Ratings:
    +1,402
    Any other way would be improper.
     
  6. supercraft002

    supercraft002 Well-Known Member

    Joined:
    Oct 24, 2014
    Messages:
    225
    Ratings:
    +64
  7. StrikerSly

    StrikerSly Well-Known Member

    Joined:
    Dec 8, 2014
    Messages:
    2,192
    Ratings:
    +745
    *still uses Turing*
     
  8. Phanta

    Phanta Well-Known Member

    Joined:
    Jan 1, 2014
    Messages:
    2,555
    Ratings:
    +997
    Code:
    public String getStuff() {
            return stuff;
    }
    
     
  9. Signatured

    Signatured War 2.0 Developer

    Joined:
    Sep 13, 2013
    Messages:
    3,819
    Ratings:
    +1,402
    >Someone says getters and setters are ugly
    >I say any other way would be improper
    >Gets quoted with a getter
    >wat
     
  10. StrikerSly

    StrikerSly Well-Known Member

    Joined:
    Dec 8, 2014
    Messages:
    2,192
    Ratings:
    +745
    This sites beginning to look like 4chan
     
  11. Phanta

    Phanta Well-Known Member

    Joined:
    Jan 1, 2014
    Messages:
    2,555
    Ratings:
    +997
    I meant to write a setter lmao
    It was because Mario's made me cringe
    Code:
    public void setFoo(Foo bar) {
            this.foo = bar;
    }
    
    EDIT: Or, alternatively use Lombok
    Code:
    @Getter @Setter private Foo bar;
    
     
    #11 Phanta, Sep 28, 2015
    Last edited: Sep 28, 2015
  12. Signatured

    Signatured War 2.0 Developer

    Joined:
    Sep 13, 2013
    Messages:
    3,819
    Ratings:
    +1,402
    Source > Gen Getters and Setters > Profit
     
  13. supercraft002

    supercraft002 Well-Known Member

    Joined:
    Oct 24, 2014
    Messages:
    225
    Ratings:
    +64
    >answerd with way that'd make them less 'ugly' :U

    he just likes to write a lot :stuck_out_tongue:
     
  14. Phanta

    Phanta Well-Known Member

    Joined:
    Jan 1, 2014
    Messages:
    2,555
    Ratings:
    +997
    1. Install Lombok
    2.
    Code:
    @Data
    public class ThisClassHasMemberVars {
    
    }
    
    3. Profit
     
  15. EmperorTrump45

    EmperorTrump45 Dank Memer

    Joined:
    Jul 3, 2015
    Messages:
    2,796
    Ratings:
    +2,157
    Okay thanks. That makes sense.

    What I got from @Mario is that polymorphism basically allows me to call on any particular public class at any time by calling on a line of code or lines of code from one of those classes.

    Am I far off the mark on that? I looked it up on Google and that's what I got from their definition :stuck_out_tongue:

    Yeah that's a good analogy. According to Google:

    Screen Shot 2015-09-28 at 8.19.01 AM.png

    if I wrote the following:

    private class LightSwitch {

    public static void main (String[] args) {

    boolean on_off = true;

    }

    }

    I would be declaring and initializing a boolean (on_off). However, isn't the boolean an identifier and on_off a literal?

    Thanks for the help everyone.
     
  16. supercraft002

    supercraft002 Well-Known Member

    Joined:
    Oct 24, 2014
    Messages:
    225
    Ratings:
    +64
    https://msdn.microsoft.com/en-us/library/aa664672(v=vs.71).aspx
     
  17. EmperorTrump45

    EmperorTrump45 Dank Memer

    Joined:
    Jul 3, 2015
    Messages:
    2,796
    Ratings:
    +2,157
  18. Paul

    Paul Well-Known Member

    Joined:
    Aug 21, 2013
    Messages:
    1,987
    Ratings:
    +904
    There wasnt anything different from yours to mine excluding the parameter types
     
  19. Phanta

    Phanta Well-Known Member

    Joined:
    Jan 1, 2014
    Messages:
    2,555
    Ratings:
    +997
    Your assignment wasn't on a newline

    An identifier is a keyword that refers to a class/interface/enum, method, field, package, or annotation.
    LightSwitch is an identifier - it refers to the class LightSwitch.
    main is an identifier - it refers to the method main.
    String is an identifier - it refers to the class String.
    args is an identifier - it refers to the parameter args.
    boolean is an identifier - it refers to the primitive type boolean.
    on_off is an identifier - it refers to the variable on_off.

    Literals are hardcoded things that stay constant, such as:
    626
    3.89F
    false
    "Hello, world!"
    'f'
     
  20. Paul

    Paul Well-Known Member

    Joined:
    Aug 21, 2013
    Messages:
    1,987
    Ratings:
    +904
    -.- i wrote that on my phone

    Gimme a break cuz
     
Loading...
Similar Threads Forum Date
Lets talk about some kit ideas! KitBrawl Mar 5, 2018
lets talk about Vote Tokens after reset Raid Aug 6, 2016
Intro lets talk Intros & Outros Apr 3, 2015
Lets all talk about our junk! MC-WarZ Jun 9, 2014
Lets talk - What should be bannable Discussion May 2, 2014
Thread Status:
Not open for further replies.
Please be aware that this thread is more than 30 days old. Do not post unless the topic can still be discussed. Read more...