Difference between revisions of "Java/C2/Primitive-type-conversions/Gujarati"

From Script | Spoken-Tutorial
Jump to: navigation, search
Line 153: Line 153:
 
|-
 
|-
 
|  03:23
 
|  03:23
| We do that by using an '''int''' in parentheses, before the variable
+
| આપણે તે વેરિયેબલ પહેલા, કૌંસ માં '''int''' નો ઉપયોગ કરી કરીશું.
  
 
 
|-
 
|-
 
|  03:34
 
|  03:34
| This statement says the data in the variable '''b''' has to be converted to '''int''' data type and stored in a.
+
| આ સ્ટેટમેન્ટ કહે છે કે વેરિયેબલ '''b''' ના ડેટા '''int''' માં ડેટા ટાઇપમાં કન્વર્ટ થાય છે અને અને a માં સંગ્રહિત થાય છે.
  
 
|-
 
|-
 
| 03:43
 
| 03:43
|   save and run the file
+
| ફાઈલ સંગ્રહ કરો અને રન કરો.
  
 
|-
 
|-
 
|  03:51
 
|  03:51
| As we can see, the '''float''' value has been converted to '''int'''.
+
| આપણે જોઈ શકીએ છીએ, '''float''' વેલ્યુ '''int''' માં કન્વર્ટ કરવામાં આવી છે.
  
  
 
|-
 
|-
 
|  03:56
 
|  03:56
| But to suit the data type, the data has been changed accordingly.
+
| પરંતુ ડેટા ટાઇપ બંધબેસાડવા માટે, ડેટા તે અનુસાર બદલવામાં આવ્યા છે.
 
+
  
 
|-
 
|-
 
|  04:01
 
|  04:01
| Explicit conversion can also be used to convert data from int to float.
+
| એક્સપ્લિક્ટ કન્વર્ઝન ડેટાને int થી float માં કન્વર્ટ કરવા માટે પણ વાપરી શકાય છે.
 
+
  
 
|-
 
|-
 
|  04:07
 
|  04:07
| Let us try  the previous example.
+
| ચાલો અગાઉના ઉદાહરણનો પ્રયાસ કરીએ.
  
 
|-
 
|-
 
|  04:10
 
|  04:10
 
|  int a =5, float b, b = float a
 
|  int a =5, float b, b = float a
 +
 
|-
 
|-
 
|  04:32
 
|  04:32
 
| '''System.out.println(b);'''
 
| '''System.out.println(b);'''
 +
 
|-
 
|-
 
|  04:36
 
|  04:36
| We are using Explicit conversion to convert integer to a ''' float'''
+
| આપણે ઈન્ટીજરથી ફ્લોટમાં કન્વર્ટ કરવા માટે એક્સપ્લિક્ટ કન્વર્ઝનનો ઉપયોગ કરી રહ્યા છીએ.
 
   
 
   
 
|-
 
|-
 
|  04:42
 
|  04:42
| Save  the file and Run it.
+
| ફાઈલ સંગ્રહ કરો અને રન કરો.
  
  
 
|-
 
|-
 
|  04:51
 
|  04:51
| we  see that  the int value has been converted  to  a '''float''' value
+
| આપણે જોશું કે int વેલ્યુ ફ્લોટ વેલ્યુમાં કન્વર્ટ કરવામાં આવી છે.
  
  
 
|-
 
|-
 
|  04:58
 
|  04:58
| Let us  see what happens when we convert  a '''character''' to an '''integer'''.
+
| ચાલો જોઈએ શું થાય છે જયારે આપણે '''character''' ને '''integer''' માં કન્વર્ટ કરીએ છીએ.
  
 
|-
 
|-
 
|  05:06
 
|  05:06
| int a,  '''char c '''''equal to in single quotes ''''''m';'''
+
| int a,  '''char c ''''' ઇકવલ ટુ, સિંગલ અવતરણ ચિહ્નમાં ''''''m';'''
  
 
'  
 
'  
 
|-
 
|-
 
|  05:24
 
|  05:24
| '''a '''''equal to ''''(int) c '''''  
+
| '''a ''''' ઇકવલ ટુ ''''(int) c '''''  
  
 
|-
 
|-
Line 222: Line 221:
 
|-
 
|-
 
|  05:36
 
|  05:36
| We are converting the  character ''' m''' to an integer and printing the value
+
| આપણે કેરેક્ટર '''m''' ને ઈન્ટીજરમાં કન્વર્ટ કરીએ છીએ અને વેલ્યુ પ્રિન્ટ કરીએ છીએ.
 +
 
 
|-
 
|-
 
|  05:43
 
|  05:43
| Let us save and run it
+
| સંગ્રહ કરો અને રન કરો.
  
 
|-
 
|-
 
|  05:53
 
|  05:53
|   As we can see, the output is 109 which the ascii value of '''m'''.  
+
| આપણે જોઈ શકીએ છીએ, આઉટપુટ 109 છે, જે '''m''' ની આસ્કી વેલ્યુ છે.
  
  
 
|-
 
|-
 
|  05:58
 
|  05:58
| It means when a '''char''' is converted to '''int''', its ascii value is stored.
+
| એનો અર્થ છે, જયારે '''char''' '''int''' માં કન્વર્ટ થાય છે, તો એની આસ્કી વેલ્યુ સંગ્રહ થાય છે.  
 
+
  
 
|-
 
|-
 
|  06:03
 
|  06:03
| Let us try this with a digit.
+
|ચાલો આ ડીજીટ સાથે પ્રયાસ કરીએ.
  
 
|-
 
|-
 
|  06:06
 
|  06:06
|  char c = digit 5   
+
|  char c = ડીજીટ 5   
  
 
|-
 
|-
 
|  06:11
 
|  06:11
Save it and run it
+
સંગ્રહ કરો અને રન કરો.
  
 
|-
 
|-
 
|  06:18
 
|  06:18
As we can see, the output is 53 which is the ascii value of the character ‘5’
+
આપણે જોઈ શકીએ છીએ, આઉટપુટ 53 છે જે 5 ની આસ્કી વેલ્યુ છે.
  
 
|-
 
|-
 
|  06:24
 
|  06:24
| It is not the number 5.
+
| તે નંબર 5 નથી.
  
  
 
|-
 
|-
 
|  06:26
 
|  06:26
| To get the number, we have to use a string and convert it to an integer.
+
| નંબર મેળવવા માટે, આપણે સ્ટ્રીંગનો ઉપયોગ કરવું પડશે અને ઈન્ટીજરમાં કન્વર્ટ કરો.
 
+
  
 
|-
 
|-
 
|  06:31
 
|  06:31
| Now let us see how to do so.
+
| ચાલો જોઈએ આ કેવી રીતે કરવું.
  
 
|-
 
|-
 
|  06:33
 
|  06:33
| Clean up the main function
+
| મેઈન ફન્કશન સાફ કરો.
  
 
|-
 
|-
 
|  06:38
 
|  06:38
| type
+
| ટાઇપ કરો,
  
  
 
|-
 
|-
 
|  06:40
 
|  06:40
|'''String sHeight ''''' string form of Height equal to in double quotes '''''6 '''''  
+
|'''String sHeight ''''' ઊંચાઈનું સ્ટ્રીંગ સ્વરૂપ , ઇકવલ ટુ, ડબલ અવતરણ ચિહ્ન અંદર '''''6 '''''  
 
+
+
  
 
|-
 
|-
 
|  06:58
 
|  06:58
|'''int h '''equal to '''explicit conversion''' to '''int of sHeight '''  and
+
|'''int h ''' ઇકવલ ટુ, એક્સપ્લિક્ટ કન્વર્ઝન, '''int of sHeight '''  અને 
 +
 
 
|-
 
|-
 
|  07:11
 
|  07:11
|'''System '''''dot''''' out '''''dot '''''println '''''  '''''h ''''' Save the file.  
+
|'''System '''''dot''''' out '''''dot '''''println '''''  '''''h ''''' ફાઈલ સંગ્રહો.  
  
 
|-
 
|-
 
|  07:27
 
|  07:27
|I’ve created a string variable with value 6 and i am trying to convert it to an integer but we see that their is an error
+
|મેં વેલ્યુ 6 સાથે સ્ટ્રીંગ વેરિયેબલ બનાવેલ છે અને હું ઈન્ટીજરમાં બદલવા માટે પ્રયાસ કરી રહ્યી છું પરંતુ આપણે જોઈએ છીએ કે અહીં એરર છે.
  
 
 
 
|-
 
|-
 
| 07:37
 
| 07:37
|   And the error message reads '''Cannot cast from String to int.'''  
+
| અને એરર મેસેજ છે, '''Cannot cast from String to int.'''
 
+
  
 
|-
 
|-
 
|  07:42
 
|  07:42
|This means for converting strings, we cannot use implicit or explicit conversion.
+
|આનો અર્થ છે, સ્ટ્રીંગ કન્વર્ટ કરવા માટે આપણે ઈમ્પ્લીસિત અથવા એક્સ્પ્લીસિત કન્વર્ઝનનો ઉપયોગ ન કરી શકીએ.
 
+
  
 
|-
 
|-
 
|  07:48
 
|  07:48
|It must be done by other methods. let us use them
+
|તે અન્ય પદ્ધતિઓ દ્વારા કરી શકાય છે. ચાલો તેનો ઉપયોગ કરીએ.
  
 
|-
 
|-
 
| 07:58
 
| 07:58
| Remove '''int sHeight ''' and type  '''''Integer '''''dot '''''parseInt  sHeight ''''.
+
|  '''int sHeight ''' રદ કરો અને ટાઇપ કરો, '''''Integer '''''dot '''''parseInt  sHeight ''''.
 +
 
 
|-
 
|-
 
|  08:21
 
|  08:21
|Save the file and run it
+
|ફાઈલ સંગ્રહ કરો અને રન કરો.
 
+
 
+
  
 
|-
 
|-
 
|  08:29
 
|  08:29
| we  see that the  value  has  been successfully  converted to an  integer.
+
| આપણે જોશું કે વેલ્યુ સફળતાપૂર્વક ઈન્ટીજરમાં કન્વર્ટ થઇ છે.
  
 
|-
 
|-
 
|  08:35
 
|  08:35
|To do this we use the''' parseInt method '''of the integer module.  
+
|આ કરવા માટે આપણે ઈન્ટીજર મોડ્યુલની '''parseInt''' મેથડનો ઉપયોગ કરીશું.
  
 
|-
 
|-
 
|  08:41
 
|  08:41
|Now let us see what happens if their are more than one digits like '''6543'''
+
|હવે ચાલો જોઈએ કે શું થશે જો ત્યાં એક કરતા વધુ ડીજીટ હોય જેમ કે '''6543'''.
 +
 
 
|-
 
|-
 
|  08:49
 
|  08:49
| Save the file and run it
+
| ફાઈલ સંગ્રહ કરો અને રન કરો.
 
+
  
 
|-
 
|-
 
|  08:55
 
|  08:55
|   We see that again the string containing the number has been successfully converted to an integer
+
આપણે જોશું કે ફરીથી નંબર ધરાવતી સ્ટ્રિંગ સફળતાપૂર્વક ઈન્ટીજરમાં કન્વર્ટ કરવામાં આવી છે.
 +
 
 
|-
 
|-
 
|  09:03
 
|  09:03
|Now let us see what happens if the strings is a floating point number
+
| હવે ચાલો જોઈએ શું થશે જો સ્ટ્રીંગ ફ્લોટિંગ પોઈન્ટ નંબર છે.
 +
 
 
|-
 
|-
 
|  09:10  
 
|  09:10  
|Change''' 6543 to65.43'''.So we have a floating point number in the strings and we are converting it to an integer
+
|'''6543 ''' ને '''65.43''' માં બદલો. તેથી આપણી પાસે સ્ટ્રીંગમાં ફ્લોટિંગ પોઈન્ટ નંબર છે અને આપણે એ ઈન્ટીજરમાં કન્વર્ટ કરીએ છીએ.  
 +
 
 
|-
 
|-
 
|  09:22
 
|  09:22
|Save the file  run it.
+
|ફાઈલ સંગ્રહો અને રન કરો.
+
 
   
 
   
 
|-
 
|-
 
|  09:31
 
|  09:31
 
|  We see that their is an error  This happens beacuse we cannot convert a  string  which contains    floating point number to an integer
 
|  We see that their is an error  This happens beacuse we cannot convert a  string  which contains    floating point number to an integer
 
  
 
|-
 
|-

Revision as of 12:02, 29 July 2013

Time' Narration
00:01 જાવામાં ટાઇપ કનવરઝન પરના સ્પોકન ટ્યુટોરીયલમાં તમારું સ્વાગત છે.
00:06 આ ટ્યુટોરીયલમાં આપણે શીખીશું:
00:08 * એક ડેટા ટાઇપમાંથી બીજા ડેટા ટાઇપમાં કેવી રીતે બદલવું.
00:13 * અહીં બે પ્રકારના કન્વર્ઝન છે, જેમના નામ છે: ઈમ્પલીસીટ અને એક્સ્પલીસીટ કન્વર્ઝન અને
00:18 * સ્ટ્રિંગ્સથી નંબરમાં કેવી રીતે બદલવું
00:23 આ ટ્યુટોરીયલ માટે આપણે ઉપયોગ કરી રહ્યા છીએ,
  • Ubuntu 11.10
  • JDK 1.6 અને
  • Eclipse 3.7
00:33 આ ટ્યુટોરીયલ અનુસરવા માટે, તમને જાવામાં ડેટા ટાઇપ માટેનું જ્ઞાન હોવું જરૂરી છે.


00:38 જો નથી, તો સંબંધિત ટ્યુટોરીયલ માટે નીચે આપેલ અમારી વેબસાઇટ જુઓ.
00:47 ટાઇપ કન્વર્ઝન નો અર્થ છે એક ડેટા ટાઇપથી બીજામાં રૂપાંતર કરવું.


00:53 ચાલો જોઈએ આ કેવી રીતે કરવું.


00:55 Eclipse પર જાઓ.
01:02 અહીં આપણી પાસે ઇક્લિપ્સ IDE છે અને બાકીના કોડ માટે જરૂરી માળખું છે.


01:07 મેં TypeConversion નામનો એક ક્લાસ બનાવ્યો છે અને તે અંદર મેઈન મેથડ ઉમેર્યી છે.


01:13 હવે ચાલો થોડા વેરીયેબલો બનાવીએ.
01:19 int a ઇકવલ ટુ5

float b

b ઇકવલ ટુ a


01:33 મેં બે વેરિયેબલ બનાવ્યા છે. a જે ઇનટીજર છે છે અને b જે ફ્લોટ છે.


01:39 હું ફ્લોટ વેરિયેબલમાં ઇનટીજર વેલ્યુ સંગ્રહ કરું છું.


01:43 ચાલો જોઈએ ફ્લોટ વેરિયેબલ હવે શું ધરાવે છે.


01:48 System dot out dot println b '


01:58 ફાઈલ સંગ્રહો અને રન કરો.
02:07 આપણે જોશું કે ઇનટીજર 5 હવે ફ્લોટ 5 .0 માં રૂપાંતરિત કરવામાં આવ્યું છે.


02:13 આ પ્રકારનું કન્વર્ઝન ઈમ્પલીસીટ કન્વર્ઝન કહેવામાં આવે છે.


02:17 નામ પ્રમાણે, વેલ્યુ આપમેળે અનુકૂળ ડેટા ટાઇપમાં કન્વર્ટ થાય છે.


02:24 હવે ચાલો સમાન પદ્ધતિનો ઉપયોગ કરી float ને int માં કન્વર્ટ કરીએ.
02:30 5 રદ કરો , float b ઇકવલ ટુ 2.5f લખો, ચાલો b ને a માં સંગ્રહીયે અને a ની વેલ્યુ પ્રિન્ટ કરો.
02:50 ફાઈલ સંગ્રહો.


02:56 આપણે જોઈએ છીએ કે ત્યાં એક એરર આવી છે.


03:00 એરર મેસેજ છે, Type mismatch: cannot convert from float to int
03:06 એનો અર્થ છે કે ઈમ્પલીસીટ કન્વર્ઝન માત્ર int થી float માં શક્ય છે પરંતુ બીજા અન્ય માર્ગમાં નહી.
03:13 float થી int માં કન્વર્ટ કરવા માટે આપણે એક્સપ્લીસીટ કન્વર્ઝનનો ઉપયોગ કરવાની જરૂર છે.


03:17 ચાલો જોઈએ એ કેવી રીતે કરવું.
03:23 આપણે તે વેરિયેબલ પહેલા, કૌંસ માં int નો ઉપયોગ કરી કરીશું.
03:34 આ સ્ટેટમેન્ટ કહે છે કે વેરિયેબલ b ના ડેટા int માં ડેટા ટાઇપમાં કન્વર્ટ થાય છે અને અને a માં સંગ્રહિત થાય છે.
03:43 ફાઈલ સંગ્રહ કરો અને રન કરો.
03:51 આપણે જોઈ શકીએ છીએ, float વેલ્યુ int માં કન્વર્ટ કરવામાં આવી છે.


03:56 પરંતુ ડેટા ટાઇપ બંધબેસાડવા માટે, ડેટા તે અનુસાર બદલવામાં આવ્યા છે.
04:01 એક્સપ્લિક્ટ કન્વર્ઝન ડેટાને int થી float માં કન્વર્ટ કરવા માટે પણ વાપરી શકાય છે.
04:07 ચાલો અગાઉના ઉદાહરણનો પ્રયાસ કરીએ.
04:10 int a =5, float b, b = float a
04:32 System.out.println(b);
04:36 આપણે ઈન્ટીજરથી ફ્લોટમાં કન્વર્ટ કરવા માટે એક્સપ્લિક્ટ કન્વર્ઝનનો ઉપયોગ કરી રહ્યા છીએ.
04:42 ફાઈલ સંગ્રહ કરો અને રન કરો.


04:51 આપણે જોશું કે int વેલ્યુ ફ્લોટ વેલ્યુમાં કન્વર્ટ કરવામાં આવી છે.


04:58 ચાલો જોઈએ શું થાય છે જયારે આપણે character ને integer માં કન્વર્ટ કરીએ છીએ.
05:06 int a, char c ઇકવલ ટુ, સિંગલ અવતરણ ચિહ્નમાં 'm';

'

05:24 a ઇકવલ ટુ '(int) c
05:32 System dot out dot println ' a.
05:36 આપણે કેરેક્ટર m ને ઈન્ટીજરમાં કન્વર્ટ કરીએ છીએ અને વેલ્યુ પ્રિન્ટ કરીએ છીએ.
05:43 સંગ્રહ કરો અને રન કરો.
05:53 આપણે જોઈ શકીએ છીએ, આઉટપુટ 109 છે, જે m ની આસ્કી વેલ્યુ છે.


05:58 એનો અર્થ છે, જયારે char int માં કન્વર્ટ થાય છે, તો એની આસ્કી વેલ્યુ સંગ્રહ થાય છે.
06:03 ચાલો આ ડીજીટ સાથે પ્રયાસ કરીએ.
06:06 char c = ડીજીટ 5
06:11 સંગ્રહ કરો અને રન કરો.
06:18 આપણે જોઈ શકીએ છીએ, આઉટપુટ 53 છે જે 5 ની આસ્કી વેલ્યુ છે.
06:24 તે નંબર 5 નથી.


06:26 નંબર મેળવવા માટે, આપણે સ્ટ્રીંગનો ઉપયોગ કરવું પડશે અને ઈન્ટીજરમાં કન્વર્ટ કરો.
06:31 ચાલો જોઈએ આ કેવી રીતે કરવું.
06:33 મેઈન ફન્કશન સાફ કરો.
06:38 ટાઇપ કરો,


06:40 String sHeight ઊંચાઈનું સ્ટ્રીંગ સ્વરૂપ , ઇકવલ ટુ, ડબલ અવતરણ ચિહ્ન અંદર 6
06:58 int h ઇકવલ ટુ, એક્સપ્લિક્ટ કન્વર્ઝન, int of sHeight અને
07:11 System dot out dot println h ફાઈલ સંગ્રહો.
07:27 મેં વેલ્યુ 6 સાથે સ્ટ્રીંગ વેરિયેબલ બનાવેલ છે અને હું ઈન્ટીજરમાં બદલવા માટે પ્રયાસ કરી રહ્યી છું પરંતુ આપણે જોઈએ છીએ કે અહીં એરર છે.
07:37 અને એરર મેસેજ છે, Cannot cast from String to int.
07:42 આનો અર્થ છે, સ્ટ્રીંગ કન્વર્ટ કરવા માટે આપણે ઈમ્પ્લીસિત અથવા એક્સ્પ્લીસિત કન્વર્ઝનનો ઉપયોગ ન કરી શકીએ.
07:48 તે અન્ય પદ્ધતિઓ દ્વારા કરી શકાય છે. ચાલો તેનો ઉપયોગ કરીએ.
07:58 int sHeight રદ કરો અને ટાઇપ કરો, Integer dot parseInt sHeight '.
08:21 ફાઈલ સંગ્રહ કરો અને રન કરો.
08:29 આપણે જોશું કે વેલ્યુ સફળતાપૂર્વક ઈન્ટીજરમાં કન્વર્ટ થઇ છે.
08:35 આ કરવા માટે આપણે ઈન્ટીજર મોડ્યુલની parseInt મેથડનો ઉપયોગ કરીશું.
08:41 હવે ચાલો જોઈએ કે શું થશે જો ત્યાં એક કરતા વધુ ડીજીટ હોય જેમ કે 6543.
08:49 ફાઈલ સંગ્રહ કરો અને રન કરો.
08:55 આપણે જોશું કે ફરીથી નંબર ધરાવતી સ્ટ્રિંગ સફળતાપૂર્વક ઈન્ટીજરમાં કન્વર્ટ કરવામાં આવી છે.
09:03 હવે ચાલો જોઈએ શું થશે જો સ્ટ્રીંગ ફ્લોટિંગ પોઈન્ટ નંબર છે.
09:10 6543 ને 65.43 માં બદલો. તેથી આપણી પાસે સ્ટ્રીંગમાં ફ્લોટિંગ પોઈન્ટ નંબર છે અને આપણે એ ઈન્ટીજરમાં કન્વર્ટ કરીએ છીએ.
09:22 ફાઈલ સંગ્રહો અને રન કરો.
09:31 We see that their is an error This happens beacuse we cannot convert a string which contains floating point number to an integer
09:41 We have to convert it to a float.Let us see how to do so;
09:45 First data type should be float,
09:51 Second we will use float . parsefloat
10:07 We are using the Parsefloat methods of the float class to convert the string containing a floating point number into an actual floating point number.
10:18 Save the file run it. We can see that the string containing a floating point number has been successfully converted to floating point number.
10:33 And this is how we do implicit and explicit conversion and How do we converts strings to numbers.
10:45 This brings us to the end of the tutorial.
10:48 In this tutorial we have learnt how to convert data from one type to another.
10:54 What is meant by implicit and explicit conversin
10:57 and How to convert strings to numbers.
11:01 As an assignment for this tutorial Read about the Integer.toString and Float.toString.


11:07 And Find out What do they do?
11:14 To know more about the Spoken Tutorial project, watch the video available at the following link,
11:20 It summarises the spoken- tutorial project.
11:23 if you do not have good bandwidth, you can download and watch it
11:27 The Spoken Tutorial Project Team. Conducts workshops using spoken tutorials
11:31 Gives certificates for those who pass an online test.
11:34 For more details, please write to contact AT spoken HYPHEN tutorial DOT org.
11:40 The Spoken Tutorial Project is a part of the Talk to a Teacher project
11:44 It is supported by theNational Mission on Education through ICT, MHRD, Government of India.
11:50 More information on this Mission is available at the following link spoken HYPHEN tutorial DOT org SLASH NMEICT HYPHEN Intro
11:55 This tutorial has been contributed by TalentSprint. Thanks for joining.



Contributors and Content Editors

Krupali, PoojaMoolya, Pratik kamble