Book book= books.addNewBook(); book.setAuthor("Fred"); book.setTitle("The Lady and a Little Dog");
Book book1 = new Book(); book1.setName("Book2"); book1.setAuthor("Author2"); Book book2 = new Book(); book2.setName("Book3"); book2.setAuthor("Author3"); ArrayList<Book> Blist = new ArrayList<Book>(); Blist.add(book1); Blist.add(book2); ArrayList<Object> list = new ArrayList<Object>(); list.add(bookstore); list.addAll(Blist);
public static void main(String[] args) { Class myClass2 = null; try { myClass2 = Class.forName("Book"); } catch (ClassNotFoundException e) { System.out.println("Error: " + e); } if (myClass2 != null) { try { //Creating an instance of the Book class Book book1 = (Book) myClass2.newInstance(); book1.setAuthor("Khan"); System.out.println(book1.getAuthor()); book1.setTitle("Second Book"); book1.setIsbn("kh_s_b"); book1.printBookDetails(); } catch (IllegalAccessException e1) { System.out.println("Error1 " + e1); } catch (InstantiationException e2) { System.out.println("Error2 " + e2); } } }//main method ends here.
book.setId(Integer.parseInt(cursor.getString(0))); book.setTitle(cursor.getString(1)); book.setAuthor(cursor.getString(2));
List<Book> list = new ArrayList<Book>(); // populate list with the results got from database while(this.results.next()) { Book book = new Book(); book.setBookID(this.results.getInt("bookID")); book.setTitle(this.results.getString("title")); book.setAuthor(this.results.getString("author")); book.setPages(this.results.getInt("pages")); list.add(book); } // set the List of Book as request attribute request.setAttribute("list",list); // forward the request to the JSP page RequestDispatcher view = request.getRequestDispatcher("view.jsp"); view.forward(request, response);
Book bk1 = new Book(); bk1.setBookId(1); bk1.setBookName("Hibernate Examples"); bk1.setAuthor("ISHTEK"); Book bk2 = (Book) session.load(Book.class, bk1);
@GET @Path("/get") @Produces(MediaType.APPLICATION_XML) public Response addObjects() { Book book = new Book(); book.setName("Here is the Game"); book.setAuthor("HHH"); BookStore bookstore = new BookStore(); bookstore.setName("Prateek Bookstore"); bookstore.setLocation("Vasanth Nagar"); ArrayList<Object> list = new ArrayList<Object>(); list.add(book); list.add(bookstore); return Response.status(200).entity(list).build(); }
public Book(String bookAuthor, String bookTitle) { author = bookAuthor; title = bookTitle; generatebook2(); } public Book(){ } public void generatebook2(){ Book book2 = new Book(); book2.setAuthor("Jumbo"); book2.setTitle("Fary"); }
byte[] bin = some binary data... Book b = new Book(); b.setAuthor("John"); b.setTitle("wild stuff"); b.setYear(2012); MultiPart multiPart = new MultiPart(); multiPart.bodyPart(new BodyPart(b, MediaType.APPLICATION_XML_TYPE)); multiPart.bodyPart(new BodyPart(bin, MediaType.APPLICATION_OCTET_STREAM_TYPE)); response = service.path("rest").path("multipart"). type(MultiPartMediaTypes.MULTIPART_MIXED). post(ClientResponse.class, multiPart);
@GET @Path("/get") @Produces(MediaType.APPLICATION_XML) public ResposeList addObjects() { Book book = new Book(); book.setName("Here is the Game"); book.setAuthor("HHH"); BookStore bookstore = new BookStore(); bookstore.setName("Prateek Bookstore"); bookstore.setLocation("Vasanth Nagar"); ArrayList<Object> list = new ArrayList<Object>(); list.add(book); list.add(bookstore); ResposeList books=new ResposeList(); books.setList(list); return books; }
// create manager and two example books SimpleBookManager manager = new SimpleBookManager(); Book harryPotter1 = manager.createBook(); Book harryPotter2 = manager.createBook(); harryPotter1.setAuthor("JK Rowling"); harryPotter1.setCourse("Harry Potter Kunskap"); harryPotter1.setPrice(199); harryPotter1.setTitle("Harry Potter and the philosifer Stone"); harryPotter1.setIsbn("9780590353403"); harryPotter2.setAuthor("JK Rowling"); harryPotter2.setCourse("Harry Potter Kunskap"); harryPotter2.setPrice(299); harryPotter2.setTitle("Harry Potter and snake"); harryPotter2.setIsbn("0439064872"); // let's use an intent to parcel the manager to Intent intent = new Intent(); intent.putExtra("extra_book_manager", manager); // read the parcelled manager back from the intent SimpleBookManager parcelledManager = intent.getParcelableExtra("extra_book_manager");
book.setTags(jobj.get("tags").getAsJsonArray()); //Assuming setTags(JsonArray ja) exists book.setName(jobj.get("price").getAsInt()); book.setAuthor(gson.fromJson(jobj.get("writer"), Author.class)); return book;
Book book = new Book(); book.setId(1); book.setAuthor("Reto Meier"); book.setTitle("Android 4 Application Development"); book.setImageUrl("http://api.androidhive.info/images/realm/1.png"); book.setAuthor("Itzik Ben-Gan"); book.setTitle("Microsoft SQL Server 2012 T-SQL Fundamentals"); book.setImageUrl("http://api.androidhive.info/images/realm/2.png"); book.setAuthor("Magnus Lie Hetland"); book.setTitle("Beginning Python: From Novice To Professional Paperback"); book.setImageUrl("http://api.androidhive.info/images/realm/3.png"); book.setAuthor("Chad Fowler"); book.setTitle("The Passionate Programmer: Creating a Remarkable Career in Software Development"); book.setImageUrl("http://api.androidhive.info/images/realm/4.png"); book.setAuthor("Yashavant Kanetkar"); book.setTitle("Written Test Questions In C Programming"); book.setImageUrl("http://api.androidhive.info/images/realm/5.png");
book = new Book(); bookshelf.getBookOrMagazine().add( book ); book.setAuthor( scanner.nextLine() ); chapters = 0; break;