Java Video类使用实例

avatar
作者
猴君
阅读量:1

下面是一个使用Java的Video类的实例:

import java.util.Date;  public class Video {     private String title;     private String description;     private String url;     private Date uploadDate;          public Video(String title, String description, String url, Date uploadDate) {         this.title = title;         this.description = description;         this.url = url;         this.uploadDate = uploadDate;     }          public String getTitle() {         return title;     }          public String getDescription() {         return description;     }          public String getUrl() {         return url;     }          public Date getUploadDate() {         return uploadDate;     }          public void setTitle(String title) {         this.title = title;     }          public void setDescription(String description) {         this.description = description;     }          public void setUrl(String url) {         this.url = url;     }          public void setUploadDate(Date uploadDate) {         this.uploadDate = uploadDate;     }          public static void main(String[] args) {         Video video = new Video("Java Tutorial", "A tutorial on Java programming language", "https://www.youtube.com/watch?v=Hl-zzrqQoSE", new Date());                  System.out.println("Title: " + video.getTitle());         System.out.println("Description: " + video.getDescription());         System.out.println("URL: " + video.getUrl());         System.out.println("Upload Date: " + video.getUploadDate());                  video.setTitle("Java Video Tutorial");                  System.out.println("New Title: " + video.getTitle());     } } 

这个例子创建了一个Video类,它有一个标题、一个描述、一个URL和一个上传日期。我们使用构造函数来创建一个Video对象,并使用getter和setter方法来访问和修改对象的属性。在主方法中,我们创建了一个Video对象并打印出它的属性。然后,我们使用setter方法修改标题,并再次打印出新的标题。

广告一刻

为您即时展示最新活动产品广告消息,让您随时掌握产品活动新动态!