• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

clone method

 
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1)class CloneTest
{

public static void main(String args[])
{
int ia[][] = {{1,2},null};
int ja[][] =(int[][])ia.clone();
System.out.println((ia==ja) + "");
System.out.println(ia[0] == ja[0] && ia[1] == ja[1]);
}
}
this method should throw CloneNotSuportedException beacause it is a checked exception
2)can anyone give me some examples where the compiler will give the error the code is unreacheable.
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For the answer to 2)
public class Test(){
public int aMethod() throws Exception
{
int x=0;
throw Exception();
return x; // this will be unreachable
}
}
 
shabbir zakir
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi!
Thanks. But what about question no.1
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,shabbir ZaKir
since all the arrays are considered to implement cloneable interface there will no exception.check with clone() in API.
regards
vkswami
 
Without deviation from the norm, progress is not possible - Zappa. Tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic