కోడ్‌జిమ్ విశ్వవిద్యాలయం కోర్సులో భాగంగా మెంటర్‌తో ఉపన్యాస స్నిప్పెట్. పూర్తి కోర్సు కోసం సైన్ అప్ చేయండి.


" జావాలో వేరియబుల్స్ పోల్చడం గురించి నేను మీకు కొంచెం చెప్పాలనుకుంటున్నాను . "

"మీకు ఇప్పటికే సరళమైన పోలిక ఆపరేటర్లు తెలుసు - (<) కంటే తక్కువ మరియు (>) కంటే ఎక్కువ."

"అవును."

"ఈక్వల్ టు (==) మరియు (!=కి సమానం కాదు) వంటి ఆపరేటర్లు కూడా ఉన్నారు. అలాగే, (<=) కంటే తక్కువ లేదా సమానం మరియు (>=) కంటే ఎక్కువ లేదా సమానం."

"ఇప్పుడు ఇది ఆసక్తికరంగా మారింది."

"జావాలో =< లేదా => ఆపరేటర్లు లేరని గమనించండి!"

" ది = సైన్ అసైన్‌మెంట్ ఆపరేషన్‌ల కోసం ఉపయోగించబడుతుంది. అందుకే సమానత్వాన్ని పరీక్షించడానికి రెండు సమాన సంకేతాలు (==) ఉపయోగించబడతాయి. వేరియబుల్స్ సమానంగా లేవని తనిఖీ చేయడానికి , != ఆపరేటర్‌ని ఉపయోగించండి ."

"అలాగా."

"== ఆపరేటర్‌ని ఉపయోగించి జావాలో రెండు వేరియబుల్‌లను పోల్చినప్పుడు, మేము వేరియబుల్స్ యొక్క కంటెంట్‌లను పోల్చాము."

"అందువలన, ఆదిమ వేరియబుల్స్ కోసం , వాటి విలువలు పోల్చబడతాయి ."

" రిఫరెన్స్ వేరియబుల్స్ కోసం , రిఫరెన్స్‌లు పోల్చబడ్డాయి . మనకు ఒకేలా కానీ విభిన్నమైన ఆబ్జెక్ట్‌లు ఉన్నాయని అనుకుందాం. వాటికి రిఫరెన్స్‌లు వేర్వేరుగా ఉన్నందున , ఒక పోలిక అవి సమానంగా లేవని చూపిస్తుంది, అంటే పోలిక ఫలితం తప్పుగా ఉంటుంది . సూచనల పోలిక నిజం అవుతుంది. రెండు సూచనలు ఒకే వస్తువును సూచిస్తే మాత్రమే. "

"ఆబ్జెక్ట్‌ల అంతర్గత విషయాలను పోల్చడానికి, మేము ప్రత్యేక సమాన పద్ధతిని ఉపయోగిస్తాము. ఈ పద్ధతి (మరియు ఆబ్జెక్ట్ క్లాస్ యొక్క అన్ని పద్ధతులు) మీరు వాటిని ప్రకటించకపోయినా కంపైలర్ ద్వారా మీ తరగతికి జోడించబడతాయి. నేను మీకు కొన్ని ఉదాహరణలను చూపుతాను: "

కోడ్ వివరణ
1
int a = 5;
int b = 5;
System.out.println(a == b);
ఆదిమ రకాలను సరిపోల్చండి .
నిజమైన స్క్రీన్‌పై ప్రదర్శించబడుతుంది.
2
Cat cat1 = new Cat("Oscar");
Cat cat2 = cat1;
System.out.println(cat1 == cat2);
సూచనలను సరిపోల్చండి .
నిజమైన స్క్రీన్‌పై ప్రదర్శించబడుతుంది.
రెండు వేరియబుల్స్ ఒకే వస్తువుకు సూచనలను నిల్వ చేస్తాయి .
3
String s = new String("Mom");
String s2 = s;
System.out.println(s == s2);
సూచనలను సరిపోల్చండి .
నిజమైన స్క్రీన్‌పై ప్రదర్శించబడుతుంది.
రెండు వేరియబుల్స్ ఒకే వస్తువుకు సూచనలను నిల్వ చేస్తాయి .
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
String s = new String("Mom");
String s2 = new String("Mom");
System.out.println(s.equals(s2));
వస్తువులను సరిపోల్చండి .
నిజమైన స్క్రీన్‌పై ప్రదర్శించబడుతుంది.
రెండు వేరియబుల్స్ ఒకేలాంటి స్ట్రింగ్ ఆబ్జెక్ట్‌లను సూచిస్తాయి

"ఓహ్, నేను దాదాపు మర్చిపోయాను! మీ కోసం ఇక్కడ కొన్ని వ్యాయామాలు ఉన్నాయి:"

4
టాస్క్
Java Syntax,  స్థాయిపాఠం
లాక్ చేయబడింది
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
టాస్క్
Java Syntax,  స్థాయిపాఠం
లాక్ చేయబడింది
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
టాస్క్
Java Syntax,  స్థాయిపాఠం
లాక్ చేయబడింది
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
టాస్క్
Java Syntax,  స్థాయిపాఠం
లాక్ చేయబడింది
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.