SlideShare a Scribd company logo
1 of 19
Principles of Computer
         Programming
                     Caucasus School of Technology




Ioseb Dzmanashvili, http://code.ge
Senior Software Architect, Picktek LLC


                      "Until programmers stop acting like obfuscation is morally
             hazardous, they’re not artists, just kids who don’t want their food to
                                                                   touch." © _why
დღევანდელი განხილვის თემები


•   ცვლადები. ცვლადების აღწერა და
    მნიშვნელობების მინიჭება.

•   პრიმიტიული და ობიექტური ტიპები.

•   მაკონტროლებელი სტრუქტურები
ცვლადი შეიძლება შევადაროთ
          უჯრას
თუმცა ცვლადი უნდა აკმაყოფილებდეს
     შესაბამის მახასიათებლებს



                    •   ტიპი.
                        int, boolean, String

                    •   სახელი.
                        age, sex, location

                    •   ზომა.
                        დამოკიდებულია ტიპზე


                    •   მნიშვნელობა
                        ტიპის შესაბამისი მნიშვნელობა
ცვლადის აღწერის მაგალითები


//სტრიქონული ტიპი
String name = “გიორგი”;

//მთელი რიცხვის ტიპი
int age = 28;

//მთელი რიცხვის ტიპი
int weight = 80;

//ლოგიკური ტიპი
boolean hasCar = true;
ცვლადები ინახება სპეციალურად გამოყოფილ
              მეხსიერებაში




                 •   ყოველი ცვლადი ინახება
                     მეხსიერების კონკრეტულ
                     მისამართზე

                 •   ყოველი ცვლადი იკავებს თავისი
                     ტიპის შესაბამის ადგილს
                     მეხსიერებაში
Java - ში არსებობს მონაცემთა ორი
              ძირითადი ტიპი



• პრიმიტიული ტიპები
 char, byte, short, int, long, float, double,
 boolean

• ობიექტური ტიპები
 String, array და ნებისმიერი კლასის ტიპი
პრიმიტიული ტიპები
  ტიპი      ზომა           min                      max

 char     16 - bit          0                     65,535
 byte      8 - bit        -128                      127
 short    16 - bit      -32,768                   32,767
  int     32 - bit   -2,147,483,648        2,147,483,647
 long     64 - bit        -2 63                   +263 - 1
 float     32 - bit     32 ბიტიანი IEEE 754 ნამდვილი რიცხვი

double    64 - bit     64 ბიტიანი IEEE 754 ნამდვილი რიცხვი

boolean    1 - bit                true ან false
ბიტები და ბაიტები

                    1 ბაიტი = 8 ბიტი
ბიტის ინდექსი          7 6 5 4 3 2 1      0
ბიტის მნიშვნელობა    128 64 32 16 8 4 2   1
                       1 1 1 1 1 1 1      1 = 256


                    1 ბაიტი = 8 ბიტი
ბიტის ინდექსი          7 6 5 4 3 2 1      0
ბიტის მნიშვნელობა    128 64 32 16 8 4 2   1
                       0 0 0 0 0 1 1      0 = ???
ლოკალური და ობიექტის
            ცვლადები


•   ლოკალური - ეწოდება მეთოდის შიგნით აღწერილ ნებისმიერ
    ცვლადს.

•   ობიექტის - ეწოდება კლასის ცვლადს რომელზე წვდომაც
    შეუძლებელია კლასის ობიექტის არსებობის გარეშე.

•   ლოკალური ცვლადები ყოველთვის ინახება სტეკში(Stack)

•   ობიექტის ცვლადები ყოველთვის ინახება გროვაში(Heap)
Stack & Heap
                              Heap
Stack

Variable 1             Object 1               Object 5

Variable 2

Variable 3                        Object 3
                  Object 6                        Object 4
Variable 4

Variable 5
                                   Object 1
ლოკალური და ობიექტის
             ცვლადები
                       ობიექტის ცვლადები
public class TestClass {
   public String name;
   public int age;
   public String gender;
}

                      ლოკალური ცვლადები
public static void main(String[] args) {
   String name = “გიორგი”;
   int age = 22;
   String gender = “mail”;
   //TestClass ობიექტის აღწერა
   TestClass test = new TestClass();
   test.name = “საბა”
   test.age = 18;
   test.name = “male”
}
ლოკალური და ობიექტის ცვლადები
               მეხსიერებაში


                              Heap
   Stack
  main მეთოდის
ლოკალური ცვლადები             “გიორგი”


     name            “male”
                                     TestClass
                                    ობიექტი
    age = 22
                                name = “საბა”
                                age = 18
    gender
                                  name =
      test
Stack & Heap
             Heap
Stack
The Simpsons



    }
           სიმპსონების ოჯახის
        ცალკეული წევრი შეგვიძლია
        აღვწეროთ შემდეგი კლასით




        public class Simpson {
           public String name;
           public int age;
           public String gender;
        }
ახლა უკვე შეგვიძლია შევქმნათ ოჯახის
       წევრები Java ობიექტების სახით

public static void main(String[] args) {

      Simpson bart = new Simpson();
      bart. name = “Bart”;
      bart. age = 12;
      bart. gender = “male”;


      Simpson homer = new Simpson();
      homer. name = “Homer”;
      homer. age = 45;
      homer. gender = “male”;


}
სიმპსონების ოჯახის წევრები გამოყოფილ
             მეხსიერებაში


                  Heap
Stack
                 Simpson
             name = “Bart”
             age = 12;
             gender = “male”;


 bart
                 Simpson
homer        name = “Homer”
             age = 45;
             gender = “male”;
შეკითხვები?
დიდი მადლობა!

More Related Content

Featured

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 

Featured (20)

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 

Java variables

  • 1. Principles of Computer Programming Caucasus School of Technology Ioseb Dzmanashvili, http://code.ge Senior Software Architect, Picktek LLC "Until programmers stop acting like obfuscation is morally hazardous, they’re not artists, just kids who don’t want their food to touch." © _why
  • 2. დღევანდელი განხილვის თემები • ცვლადები. ცვლადების აღწერა და მნიშვნელობების მინიჭება. • პრიმიტიული და ობიექტური ტიპები. • მაკონტროლებელი სტრუქტურები
  • 4. თუმცა ცვლადი უნდა აკმაყოფილებდეს შესაბამის მახასიათებლებს • ტიპი. int, boolean, String • სახელი. age, sex, location • ზომა. დამოკიდებულია ტიპზე • მნიშვნელობა ტიპის შესაბამისი მნიშვნელობა
  • 5. ცვლადის აღწერის მაგალითები //სტრიქონული ტიპი String name = “გიორგი”; //მთელი რიცხვის ტიპი int age = 28; //მთელი რიცხვის ტიპი int weight = 80; //ლოგიკური ტიპი boolean hasCar = true;
  • 6. ცვლადები ინახება სპეციალურად გამოყოფილ მეხსიერებაში • ყოველი ცვლადი ინახება მეხსიერების კონკრეტულ მისამართზე • ყოველი ცვლადი იკავებს თავისი ტიპის შესაბამის ადგილს მეხსიერებაში
  • 7. Java - ში არსებობს მონაცემთა ორი ძირითადი ტიპი • პრიმიტიული ტიპები char, byte, short, int, long, float, double, boolean • ობიექტური ტიპები String, array და ნებისმიერი კლასის ტიპი
  • 8. პრიმიტიული ტიპები ტიპი ზომა min max char 16 - bit 0 65,535 byte 8 - bit -128 127 short 16 - bit -32,768 32,767 int 32 - bit -2,147,483,648 2,147,483,647 long 64 - bit -2 63 +263 - 1 float 32 - bit 32 ბიტიანი IEEE 754 ნამდვილი რიცხვი double 64 - bit 64 ბიტიანი IEEE 754 ნამდვილი რიცხვი boolean 1 - bit true ან false
  • 9. ბიტები და ბაიტები 1 ბაიტი = 8 ბიტი ბიტის ინდექსი 7 6 5 4 3 2 1 0 ბიტის მნიშვნელობა 128 64 32 16 8 4 2 1 1 1 1 1 1 1 1 1 = 256 1 ბაიტი = 8 ბიტი ბიტის ინდექსი 7 6 5 4 3 2 1 0 ბიტის მნიშვნელობა 128 64 32 16 8 4 2 1 0 0 0 0 0 1 1 0 = ???
  • 10. ლოკალური და ობიექტის ცვლადები • ლოკალური - ეწოდება მეთოდის შიგნით აღწერილ ნებისმიერ ცვლადს. • ობიექტის - ეწოდება კლასის ცვლადს რომელზე წვდომაც შეუძლებელია კლასის ობიექტის არსებობის გარეშე. • ლოკალური ცვლადები ყოველთვის ინახება სტეკში(Stack) • ობიექტის ცვლადები ყოველთვის ინახება გროვაში(Heap)
  • 11. Stack & Heap Heap Stack Variable 1 Object 1 Object 5 Variable 2 Variable 3 Object 3 Object 6 Object 4 Variable 4 Variable 5 Object 1
  • 12. ლოკალური და ობიექტის ცვლადები ობიექტის ცვლადები public class TestClass { public String name; public int age; public String gender; } ლოკალური ცვლადები public static void main(String[] args) { String name = “გიორგი”; int age = 22; String gender = “mail”; //TestClass ობიექტის აღწერა TestClass test = new TestClass(); test.name = “საბა” test.age = 18; test.name = “male” }
  • 13. ლოკალური და ობიექტის ცვლადები მეხსიერებაში Heap Stack main მეთოდის ლოკალური ცვლადები “გიორგი” name “male” TestClass ობიექტი age = 22 name = “საბა” age = 18 gender name = test
  • 14. Stack & Heap Heap Stack
  • 15. The Simpsons } სიმპსონების ოჯახის ცალკეული წევრი შეგვიძლია აღვწეროთ შემდეგი კლასით public class Simpson { public String name; public int age; public String gender; }
  • 16. ახლა უკვე შეგვიძლია შევქმნათ ოჯახის წევრები Java ობიექტების სახით public static void main(String[] args) { Simpson bart = new Simpson(); bart. name = “Bart”; bart. age = 12; bart. gender = “male”; Simpson homer = new Simpson(); homer. name = “Homer”; homer. age = 45; homer. gender = “male”; }
  • 17. სიმპსონების ოჯახის წევრები გამოყოფილ მეხსიერებაში Heap Stack Simpson name = “Bart” age = 12; gender = “male”; bart Simpson homer name = “Homer” age = 45; gender = “male”;