Learn Java - Exercise 01x - Methods in Java

แชร์
ฝัง
  • เผยแพร่เมื่อ 23 ม.ค. 2025

ความคิดเห็น • 21

  • @dmg-s
    @dmg-s 4 ปีที่แล้ว +8

    I don't have any kind of method to return my "Gratitude" into your method.. It's all void.
    UR THE BEST

  • @lavexitosh
    @lavexitosh ปีที่แล้ว

    The best out there on this topic!

  • @miracielmurillo9574
    @miracielmurillo9574 4 ปีที่แล้ว +2

    You can also switch case and call the methods from another class.

  • @jeanjulmis2347
    @jeanjulmis2347 2 ปีที่แล้ว

    I am glad I tried the exercises first. I used method to write my code since we are learning about method. If anyone wants to see my code, I'll post it.

  • @ogunmiluaabiodun4287
    @ogunmiluaabiodun4287 5 ปีที่แล้ว +3

    you have made java interesting for me, just when i was almost giving up on it..can't seem to find anything on arrays. if you could please help with that as well... Bless up.

    • @sinisatesic8737
      @sinisatesic8737 4 ปีที่แล้ว

      th-cam.com/video/2eKjuhzI87g/w-d-xo.html

  • @fatimax7595
    @fatimax7595 2 ปีที่แล้ว

    Another really helpful video! Thank you

  • @myimmortal9488
    @myimmortal9488 4 ปีที่แล้ว +2

    package Method;
    import java.util.Scanner;
    public class Methods {
    public static void main(String[] args) {
    int number =0;

    System.out.println(" hi enter a number ");

    Scanner input= new Scanner(System.in);

    number= input.nextInt();

    if (number==1) {
    spring();}
    else if ( number ==2 )
    summer();
    else if ( number ==3)
    autum();
    else if ( number == 4)
    winter();
    else System.out.println( " be sure the number from 1 to 4");

    }


    public static void spring() {
    System.out.println( " it is spring");
    }
    public static void summer () {
    System.out.println( " it is summer ");
    }
    public static void autum () {
    System.out.println( " it is autum ");}
    public static void winter ()
    {
    System.out.println( " it is winter ");}
    }

  • @raz0229
    @raz0229 6 ปีที่แล้ว +3

    Can i buy the whole volume in Blu-Ray?

    • @MathAndScience
      @MathAndScience  6 ปีที่แล้ว +2

      Sorry I don't make them on blu-ray. For the highest resolution, visit www.mathtutordvd.com and you can purchase the set as a download. Thank you!

    • @raz0229
      @raz0229 6 ปีที่แล้ว +2

      @@MathAndScience ThankX for free!

  • @raymondRodriguez
    @raymondRodriguez 2 ปีที่แล้ว

    very well explained

  • @musasavage701
    @musasavage701 4 ปีที่แล้ว +3

    to every CS student checking the comments to see if this is worth watching
    public static void printRecommendation(){
    System.out.println("this is the best");
    }

  • @AONK
    @AONK 2 ปีที่แล้ว

    package lesson1;
    import java.util.Scanner;
    public class Lesson1Exercise {
    public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    int userInput;
    System.out.println("Please enter a season of your choice.
    1 = Spring
    2 = Summer
    3 = Fall
    4 = Winter
    ");

    do {
    userInput = input.nextInt();
    switch(userInput) {
    case 1: printSpring();
    break;
    case 2: printSummer();
    break;
    case 3: printFall();
    break;
    case 4: printWinter();
    break;
    default: System.err.println("Enter a seasonal number between 1-4: ");
    break;
    }
    }while((userInput < 1) || (userInput > 4));
    }

    public static void printSpring() {
    System.out.println("The season is Spring, and the flowers are blooming!");
    }

    public static void printSummer() {
    System.out.println("The season is Summer, and it is getting hot!");
    }

    public static void printFall() {
    System.out.println("The season is Fall, and leaves are falling!");
    }

    public static void printWinter() {
    System.out.println("The season is Winter, and it is snowing!");
    }
    }

    • @AONK
      @AONK 2 ปีที่แล้ว

      i spent a while trying to add a way to send an error message if you type something other than an integer but could not work out what structure it would work in

  • @andreirotaru.c
    @andreirotaru.c 4 ปีที่แล้ว

    import java.util.Scanner;
    public class JavaLearn {
    public static void main(String[] args) {
    Scanner sezoane = new Scanner(System.in);
    int numar = 1;

    System.out.println("Pentru fiecare sezon on parte scrie de la 1 la 4");
    numar = sezoane.nextInt();
    if (numar == 1) {
    printPrimavara;
    if (numar == 2) {
    printVara();
    if (numar == 3) {
    printToamna();
    if (numar == 4) {
    printIarna();
    }
    public static void printPrimavara () {
    System.out.println("Este primavara si este totul numai flori");
    }
    public static void printVara () {
    System.out.println("Este vara si caldura este infernala");
    }
    public static void printToamna () {
    System.out.println("Este toamna, iar frigul si frunzele se lasa");
    }
    public static void printIarna () {
    System.out.println("A venit iarna si zapada este prezenta peste tot");
    }
    }
    What is wrong here because does not work

    • @ryanchau103
      @ryanchau103 3 ปีที่แล้ว +1

      You do not need an opening bracket for each of the if statement. It is reading as a single line.

    • @andreirotaru.c
      @andreirotaru.c 3 ปีที่แล้ว

      @@ryanchau103 🙏