CodeGym/জাভা কোর্স/জাভা সিনট্যাক্স/তুলনা করা এবং শর্ত সেট করা

তুলনা করা এবং শর্ত সেট করা

বিদ্যমান
2
কাজ
জাভা সিনট্যাক্স,  লেভেল 4পাঠ 6
লক করা আছে
18+
Would any child close a website after being informed that it is not intended for anybody under 18? Despite being entirely ineffective, this age "verification" process is still used. Let's write a program that asks the user's age. If the answer is <18, the program displays "Grow up a little more".
2
কাজ
জাভা সিনট্যাক্স,  লেভেল 4পাঠ 6
লক করা আছে
Bouncer policy
The Chastity nightclub has commissioned Company X to make an automatic bouncer. A junior developer (you) was instructed to write a visitor identification method that includes an age check. Would-be guests need to use the keyboard to enter their name and age. If the age is 20 or more, the auto-bouncer should assure the guest that everything is OK—18 is old enough.
4
কাজ
জাভা সিনট্যাক্স,  লেভেল 4পাঠ 6
লক করা আছে
Three numbers
Keyboard input, numeric comparisons, and screen output—4th-level CodeGym students hone these skills until they are automatic. Let's write a program where the user enters three numbers from the keyboard. Then we'll perform a comparison. If we find a number that differs from the other two, we'll display its ordinal number.
2
কাজ
জাভা সিনট্যাক্স,  লেভেল 4পাঠ 6
লক করা আছে
Target locked!
A military robot has been equipped with a sight that helps it shoot down enemy tin cans. An informant passes the robot the enemy's surface coordinates (latitude and longitude). Let's write a program that helps the robot calculate the quadrant where the enemy tin can is located.

কোডজিম ইউনিভার্সিটি কোর্সের অংশ হিসাবে একজন পরামর্শদাতার সাথে একটি বক্তৃতা স্নিপেট। সম্পূর্ণ কোর্সের জন্য সাইন আপ করুন।


"আমি আপনাকে জাভাতে ভেরিয়েবলের তুলনা করার বিষয়ে কিছু বলতে চাই । "

"আপনি ইতিমধ্যেই সবচেয়ে সহজ তুলনা অপারেটর জানেন - (<) এর চেয়ে কম এবং (>) এর চেয়ে বেশি।"

"হ্যাঁ।"

"এমনও অপারেটর আছে যেমন সমান (==) এবং সমান নয় (!=)। পাশাপাশি, (<=) এর চেয়ে কম বা সমান এবং (>=) এর চেয়ে বড় বা সমান।"

"এখন এটি আকর্ষণীয় হয়ে উঠছে।"

"উল্লেখ্য যে জাভাতে কোন =< বা => অপারেটর নেই!"

" = চিহ্নটি অ্যাসাইনমেন্ট ক্রিয়াকলাপের জন্য ব্যবহৃত হয়। তাই সমানতা পরীক্ষা করতে দুটি সমান চিহ্ন (==) ব্যবহার করা হয়। ভেরিয়েবলগুলি সমান নয় কিনা তা পরীক্ষা করতে , != অপারেটর ব্যবহার করুন ।"

"আমি দেখি."

"== অপারেটর ব্যবহার করে জাভাতে দুটি ভেরিয়েবলের তুলনা করার সময়, আমরা ভেরিয়েবলের বিষয়বস্তুর তুলনা করছি।"

"এইভাবে, আদিম ভেরিয়েবলের জন্য , তাদের মান তুলনা করা হয় ।"

" রেফারেন্স ভেরিয়েবলের জন্য , রেফারেন্সগুলি তুলনা করা হয় । ধরুন আমাদের অভিন্ন কিন্তু স্বতন্ত্র বস্তু আছে। কারণ তাদের রেফারেন্সগুলি ভিন্ন , একটি তুলনা দেখাবে যে তারা সমান নয়, অর্থাৎ তুলনা ফলাফল মিথ্যা হবে । রেফারেন্সের তুলনা সত্য হবে শুধুমাত্র যদি উভয় রেফারেন্স একই বস্তুর দিকে নির্দেশ করে। "

"অবজেক্টের অভ্যন্তরীণ বিষয়বস্তু তুলনা করার জন্য, আমরা বিশেষ সমান পদ্ধতি ব্যবহার করি। এই পদ্ধতিটি (এবং অবজেক্ট ক্লাসের সমস্ত পদ্ধতি) কম্পাইলার দ্বারা আপনার ক্লাসে যোগ করা হয় যদিও আপনি সেগুলি ঘোষণা না করেন। আমি আপনাকে কিছু উদাহরণ দেখাই: "

কোড ব্যাখ্যা
1
int a = 5;
int b = 5;
System.out.println(a == b);
আদিম প্রকারের তুলনা করুন ।
true পর্দায় প্রদর্শিত হবে।
2
Cat cat1 = new Cat("Oscar");
Cat cat2 = cat1;
System.out.println(cat1 == cat2);
রেফারেন্স তুলনা করুন .
true পর্দায় প্রদর্শিত হবে।
উভয় ভেরিয়েবল একই বস্তুর রেফারেন্স সংরক্ষণ করে ।
3
String s = new String("Mom");
String s2 = s;
System.out.println(s == s2);
রেফারেন্স তুলনা করুন .
true পর্দায় প্রদর্শিত হবে।
উভয় ভেরিয়েবল একই বস্তুর রেফারেন্স সংরক্ষণ করে ।
4
Cat cat1 = new Cat("Oscar");
Cat cat2 = new Cat("Oscar");
System.out.println(cat1 == cat2);
রেফারেন্স তুলনা করুন .
মিথ্যা পর্দায় প্রদর্শিত হবে।
দুটি ভেরিয়েবল অভিন্ন বিড়াল বস্তুর উল্লেখ করে, কিন্তু একই নয়।
5
String s = new String("Mom");
String s2 = new String("Mom");
System.out.println(s == s2);
রেফারেন্স তুলনা করুন .
মিথ্যা পর্দায় প্রদর্শিত হবে।
দুটি ভেরিয়েবল অভিন্ন স্ট্রিং বস্তুর উল্লেখ করে, কিন্তু একই নয়।
6
Cat cat1 = new Cat("Oscar");
Cat cat2 = new Cat("Oscar");
System.out.println(cat1.equals(cat2));
বস্তুর তুলনা করুন ।
true পর্দায় প্রদর্শিত হবে।
দুটি ভেরিয়েবল অভিন্ন বিড়াল বস্তুর উল্লেখ করে
7
String s = new String("Mom");
String s2 = new String("Mom");
System.out.println(s.equals(s2));
বস্তুর তুলনা করুন ।
true পর্দায় প্রদর্শিত হবে।
দুটি ভেরিয়েবল অভিন্ন স্ট্রিং বস্তুর উল্লেখ করে

"ওহ, আমি প্রায় ভুলে গেছি! এখানে আপনার জন্য কিছু ব্যায়াম আছে:"

4
কাজ
জাভা সিনট্যাক্স,  লেভেল 4পাঠ 6
লক করা আছে
Minimum of two numbers
All search and sort algorithms are based on comparisons. You'll be able to handle these very soon, if you so desire. In the meantime, we suggest starting with something small: write a program to find the minimum of two numbers. Find it and then display it. And if the numbers are the same, display either of them.
4
কাজ
জাভা সিনট্যাক্স,  লেভেল 4পাঠ 6
লক করা আছে
Maximum of four numbers
Finding the maximum is an n-ary operation (an operation on n numbers) that returns the largest of several numbers. Never mind. We have no need for such definitions at the secret CodeGym center. We're here to learn how to write code. In this task, you need to use the keyboard to enter four numbers. Then determine the largest of them and display it on the screen.
8
কাজ
জাভা সিনট্যাক্স,  লেভেল 4পাঠ 6
লক করা আছে
Sorting three numbers
Planet Linear Chaos is populated by isomorphs. They are believed to have invented sorting algorithms. Everything in their heads is extremely well-ordered. They only issue planetary visas to people who know at least 7 sorting algorithms. Let's take our first step toward Linear Chaos: Read three numbers from the keyboard, put them in descending order, and then display them on the screen.
4
কাজ
জাভা সিনট্যাক্স,  লেভেল 4পাঠ 6
লক করা আছে
Jen or Jen?
Jen, Company X's admin, learned how to pilot a space ship and flew away to another planet. People in Company X are good and sincere. It's just that they're scatterbrained and they mix up names. So they decided that the new administrator would also be called Jen. Let's help Company X find their Jen: write a program that checks the identity of two entered names.
মন্তব্য
  • জনপ্রিয়
  • নতুন
  • পুরানো
মন্তব্য লেখার জন্য তোমাকে অবশ্যই সাইন ইন করতে হবে
এই পাতায় এখনও কোনো মন্তব্য নেই